Hi there,
I'm trying to use OnKeyDown to find out what key was pressed; however,
when I want, say *, it always returns 8 (or rather KeyEvent.KEYCODE_8,
or I can use any one of a number of KeyEvent methods to get the
unicode value for 8, but not *).
If I press Alt then 8, I'll get the key down for Alt, but when I press
8, neither isAltPressed nor getMetaState indicate that the Alt was
pressed. Nonetheless, in a text field, this will give me a *, but in
my app, I get an 8.
Do I need to manually keep track of whether the Alt key was pressed
and then map the non-alt key to the alt-key value? That seems wrong,
since it's possible that future phones might not have the same
keyboard layout. Even the keyboard layout of the emulator and the G1
don't exactly match. My emulator has /? to the right of the space
key, but my G1 has ./
If you need example code:
public boolean onKeyDown(int keyCode, KeyEvent msg) {
switch (keyCode) {
case KeyEvent.KEYCODE_0:
case KeyEvent.KEYCODE_1:
case KeyEvent.KEYCODE_2:
case KeyEvent.KEYCODE_3:
case KeyEvent.KEYCODE_4:
case KeyEvent.KEYCODE_5:
case KeyEvent.KEYCODE_6:
case KeyEvent.KEYCODE_7:
case KeyEvent.KEYCODE_8:
case KeyEvent.KEYCODE_9:
AppendNumber(keyCode - KeyEvent.KEYCODE_0);
return true;
case KeyEvent.KEYCODE_STAR: //this never gets called because
I'm always getting KEYCODE_8.
AppendOp("*");
return true;
}
return false;
}
Note that I've tried it with getting the code from msg with no luck.
Any help?
Thanks,
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---