Wiki
Clone wikidsair / InputManager
HOWTO: InputManager: Binding and unbinding keys
Introduction
The InputManager deals with binding different keys to functions. There's also convenience functions in the DSAir
class.
Details
Check out the TestInput.as file for the full details.
As with all examples, you need to init the framework before doing anything:
#!actionscript DSAir.init( this ); // "this" is your Document class
##Binding a key##
Simply call:
#!actionscript InputManager.instance.bind( Keyboard.SPACE, this._onSpace );
or
#!actionscript DSAir.bindKey( Keyboard.SPACE, this._onSpace );
to bind a key to a function. Use the Flash Keyboard
class for the key constants. The callback function should take one parameter of type KeyboardEvent
.
##Unbinding a key##
#!actionscript InputManager.instance.unbind( Keyboard.SPACE );
or
#!actionscript DSAir.unbindKey( Keyboard.SPACE );
will do the job
Updated