03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

The following example creates a new listener object <strong>and</strong> defines a function for onKeyDown <strong>and</strong><br />

onKeyUp. The last line uses addListener() to register the listener with the Key object so that<br />

it can receive notification from the key down <strong>and</strong> key up events.<br />

var myListener:Object = new Object();<br />

myListener.onKeyDown = function () {<br />

trace ("You pressed a key.");<br />

}<br />

myListener.onKeyUp = function () {<br />

trace ("You released a key.");<br />

}<br />

Key.addListener(myListener);<br />

See also<br />

getCode (Key.getCode method), isDown (Key.isDown method), onKeyDown<br />

(Key.onKeyDown event listener), onKeyUp (Key.onKeyUp event listener),<br />

removeListener (Key.removeListener method)<br />

BACKSPACE (Key.BACKSPACE property)<br />

public static BACKSPACE : Number<br />

The key code value for the Backspace key (8).<br />

Example<br />

The following example creates a new listener object <strong>and</strong> defines a function for onKeyDown.<br />

The last line uses addListener() to register the listener with the Key object so that it can<br />

receive notification from the key down event.<br />

var keyListener:Object = new Object();<br />

keyListener.onKeyDown = function() {<br />

if (Key.isDown(Key.BACKSPACE)) {<br />

trace("you pressed the Backspace key.");<br />

} else {<br />

trace("you DIDN'T press the Backspace key.");<br />

}<br />

};<br />

Key.addListener(keyListener);<br />

When using this example, make sure that you select Control > Disable Keyboard Shortcuts in<br />

the test environment.<br />

CAPSLOCK (Key.CAPSLOCK property)<br />

public static CAPSLOCK : Number<br />

Key 347

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!