Capturing special key presses (shift, alt) of the Soft / OnScreen keyboard
<p>I am trying to capture the key-press for the shift or alt keys and it seems to work just fine with the physical keyboard.  Unfortunately when I test the same code with the onScreen keyboard it doesn't respond at all (I've tried a 2.1, 4.03 emulator and 2.3 physical device).</p>

<p>This seems to be a platform issue that probably has no workaround, but as a last ditch effort I wanted to post the question here to see if anyone has found one (I am willing to entertain any ideas).</p>

<p>Thanks!</p>

<p><strong>Edit to clarify my point:</strong>  I tried putting a breakpoint on the " if (event.getAction() == KeyEvent.ACTION_DOWN) " line, and it will always stop if I press the shift of the physical keyboard, but never when I press the shift of the onScreenKeyboard.  So, the problem is that onKey is not being executed for all keypresses of the onScreenKeyboard.</p>

<pre><code>public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mEditText1 = (EditText) findViewById(R.id.editText1);

    mEditText1.setOnKeyListener( new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_DOWN)
            {
                switch (keyCode)
                {
                    case KeyEvent.KEYCODE_DPAD_CENTER:
                    case KeyEvent.KEYCODE_ENTER:
                        Toast.makeText(IMETestActivity.this, "Enter was consumed",
                                Toast.LENGTH_SHORT).show();
                        return true;

                    case KeyEvent.META_SHIFT_LEFT_ON:
                    case KeyEvent.META_SHIFT_RIGHT_ON:
                        Toast.makeText(IMETestActivity.this, "Meta Shift was consumed",
                                Toast.LENGTH_SHORT).show();
                        return true;

                    case KeyEvent.KEYCODE_SHIFT_LEFT:
                    case KeyEvent.KEYCODE_SHIFT_RIGHT:
                        Toast.makeText(IMETestActivity.this, "Shift was consumed",
                                Toast.LENGTH_SHORT).show();
                        return true;

                    default:
                        break;
                }
            }

            return false;
        }
    });

}
</code></pre>
