Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Handling keypress events in Flash Lite

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

This article shows how to handle keypress events in Flash Lite using the on handler or a key listener (Flash Lite 2.x only). It also lists the key constants.

Article Metadata
Platform(s): Flash Lite: 1.1, 2.x
Created: soueldi (29 May 2007)
Last edited: hamishwillee (14 May 2013)

Handling keypress event using the on handler

A way to handle a keypress event is using this statement:

on(keyPress aKeyCode) {A command handling code}

This example shows you how to handle "Up" and "9" keypress events:

  • Using the Text tool, drag a static text field outside your document.
    Handle keyevent.jpg
  • Convert this text into a button: Select the text field -> Right click -> Convert to Symbol -> Select Button
  • Open the Actions panel and add the following code:
    on(keyPress "<Up>") 
    trace("You have pressed the Up key");
    //Add your command handling code here
    on(keyPress "9")
    //Add your command handling code here

List of key constants

To handle the Soft Keys, you must first call the SetSoftKeys command.

Device button Keypress code
0-9, *, # 0-9, *, #
Left Arrow key <Left>
Right Arrow key <Right>
Up Arrow key <Up>
Down Arrow key <Down>
Select key <Enter>
Left soft key <PageUp>
Right soft key <PageDown>

Handling keypress events using a key listener (Flash Lite 2.x only)

//Create a listener object named keyListener 
var keyListener:Object = new Object();
//Define a function that responds to the KeyDown event
keyListener.onKeyDown = function()
if (Key.getCode() == Key.UP)
trace("You have pressed the Up key");
//Add your command handling code here
trace("You have pressed: "+Key.getCode());
//The keyListener object is then registered to the Key object

For handling the Soft Keys using a key listener, see Flash Lite 2.0 Soft Keys Example

This page was last modified on 14 May 2013, at 03:18.
28 page views in the last 30 days.