http://code.google.com/p/bigroom/wiki/KeyPoll
http://bigroom.googlecode.com/files/KeyPoll.zip
put the KeyPoll.as file in the folder with your main swf.
From your document class, the main one, do
to call it from your otherclasses/functions you use.Code:import flash.ui.keyboard; ... public static var Key:KeyPoll= new KeyPoll(stage);
Alternatively, you can make your own Keys.as class that simply has the key codes for the key code you need like this:Code:if("Document class name".Key.isDown(Keyboard.ENTER)){ call function }
Use another public static variable for Keys like the KeyPoll.Code:package { public class Keys { public function Keys() { } public var Left:int = 37; public var Up:int = 38; public var Right:int = 39; public var Down:int = 40; } }
EDIT: I forgot you need to put stage in the KeyPoll parameters




Reply With Quote