The following physical keys can be mapped to MIDP-defined logical key
events. Keys marked with * are only visible on FullCanvas
and
in Canvas
in full screen mode when there are no CommandListener
or Command
s
set.
Physical Key |
Key code decimal value |
---|---|
Up |
-1 |
Down |
-2 |
Left |
-3 |
Right |
-4 |
Clear key |
-8 |
Edit key |
-50 |
End key |
-11 |
Send key |
-10 |
Applications key |
-12 |
Voice key |
-13 |
Play/pause |
-20 |
Previous |
-21 |
Next |
-22 |
Stop |
-23 |
Selection key |
-5 (not always returned from S60 3rd Edition FP 2 onwards, see Nokia-MIDlet-S60-Selection-Key-Compatibility JAD attribute) |
Softkey1 (left softkey |
-6 |
Softkey2 (right softkey) |
-7 |
Zoom in |
-63582 |
Zoom out |
-63583 |
Some devices support 9-way navigation, which means that in addition
to the four main directional keys, the device can also detect key presses
to four diagonal directions. If the user presses into a diagonal direction
on such a device, the Canvas
or CustomItem
receives
two orthogonal key events from the adjacent main directions according to the
following table:
Pressed diagonal key |
Translated key events |
Key code decimal values |
---|---|---|
Left upwards direction |
Up and Left |
|
Right upwards direction |
Up and Right |
|
Left downwards direction |
Down and Right |
|
Right downwards direction |
Down and Left |
|
The reason for separating the diagonal key presses is to maintain backwards compatibility for legacy MIDlets. Java Runtime translates single diagonal key press events to two orthogonal key press events.
Note: The End
key event is used by the system to exit
the MIDlet and to go to the device’s Idle state (or to terminate active calls).
A MIDlet can however explicitly define if it is closed or continues to run
in the background.
Note: Some keys defined in above table may not be available with a full keyboard. For example, the Clear key is not available, because the full keyboard contains the backspace key whose Unicode value is 8. Note also that pressing the Shift key alone in a full keyboard causes a key event with the key code 50 (an Edit key event). If the Shift key is pressed together with another key, it causes only the combined key event, not the Edit key event with the key code 50.
A full keyboard contains also other standard physical keys, including letters and characters such as @ and +. Their key codes are equal to the Unicode value for the corresponding character. For example, the letter key A has the key code 97 and its key name string is a. A full keyboard provides also combined keys, for example Shift+A has the key code 65 and its key name string is A.
Physical key |
Key code |
---|---|
Space |
32 |
Backspace |
8 |
Escape |
27 |
Tab |
9 |
Enter |
10 |
Delete |
127 |
Every modifier key on keyboard (Shift, Fn, Ctrl) delivers a key event
with key code -50 to Canvas
and CustomItem
key
press methods. Key events from special keys such as Chr, zoom
keys, and others are also delivered to MIDlet but they do not function in
any special way. Thus, the MIDlet can do what they want for these key events.
Modifier keys (Shift, Fn, Ctrl) pressed along with other keys send combined key events (for example, pressing Fn+A sends @).
Modifier keys act as 'sticky' keys, modifying the immediately following character event. In other words, the end user does not have to keep the Fn key pressed down while entering the special letter. Pressing the key once is enough.
Pressing a modifier key twice locks the modifier key. Every following key press delivers modified key codes. Every locked modifier key except Shift can be unlocked by pressing it again. Pressing a locked Shift key unlocks it for one following key press. The Shift modifier is unlocked completely by pressing it twice.
Several system properties are closely related to using modifier keys. For more information, see section System properties.