Media keys

Nokia devices are equipped with media keys from S60 3rd Edition FP 2 and Series 40 5th Edition onwards. Media keys are play/pause, stop, previous/rewind, and next/fast forward.

Media key events are not created by default. In order for a MIDlet to be notified by media key events, the JAD attributeNokia-UI-Enhancement must have value MusicKeysSupported set, as described in table Nokia proprietary JAD attributes.

Media key events are delivered to all Canvas and CustomItem objects even when they are not the current Displayable or the focused item on a Form. Thus media applications can be managed without setting the MIDlet on the foreground. This can be especially useful when the MIDlet is managed via an accessory and the device is not at hand.

Media key presses are received with the keyPressed (int keyCode) method. If the MIDlet contains more than one active Canvas or CustomItem objects, you need to carefully manage what Canvas or CustomItem object(s) (if any) handle media key events, as all these objects will get a media key event when it occurs.

If the MIDlet contains more than one active Canvas or CustomItem objects, it is MIDlet developer’s responsibility to manage what Canvas or CustomItem object(s) (if any) handles media key events, because all these objects will get a media key event when it occurs.

For key codes of media keys, see table Additional physical keys.

Table: Key events of media keys

Media key

Key event generated by short key press

Key event generated by long key press

Play/Pause

Stop

keyPressed

keyPressed

Previous/Rewind

Next/Fast Forward

keyPressed

keyPressed (on initial press)

keyRepeated (while holding down the key)

keyReleased (when releasing the key)