Key.hx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package flash;
  2. #if flash_strict
  3. typedef KeyListener = {
  4. function onKeyDown() : Void;
  5. function onKeyUp() : Void;
  6. }
  7. #end
  8. extern class Key
  9. {
  10. static var ALT : Int = 18;
  11. static var ENTER : Int = 13;
  12. static var SPACE : Int = 32;
  13. static var UP : Int = 38;
  14. static var DOWN : Int = 40;
  15. static var LEFT : Int = 37;
  16. static var RIGHT : Int = 39;
  17. static var PGUP : Int = 33;
  18. static var PGDN : Int = 34;
  19. static var HOME : Int = 36;
  20. static var END : Int = 35;
  21. static var TAB : Int = 9;
  22. static var CONTROL : Int = 17;
  23. static var SHIFT : Int = 16;
  24. static var ESCAPE : Int = 27;
  25. static var INSERT : Int = 45;
  26. static var DELETEKEY : Int = 46;
  27. static var BACKSPACE : Int = 8;
  28. static var CAPSLOCK : Int = 20;
  29. // hide : static property _listeners(default,null) : Array<Dynamic>;
  30. static function getAscii():Int;
  31. static function getCode():Int;
  32. static function isDown(code:Int):Bool;
  33. static function isToggled(code:Int):Bool;
  34. static dynamic function onKeyDown() : Void;
  35. static dynamic function onKeyUp() : Void;
  36. #if flash_strict
  37. static function addListener(listener:KeyListener):Void;
  38. static function removeListener(listener:KeyListener):Bool;
  39. #else
  40. static function addListener(listener:Dynamic):Void;
  41. static function removeListener(listener:Dynamic):Bool;
  42. #end
  43. private static function __init__() : Void untyped {
  44. flash.Key = _global["Key"];
  45. flash.Key.addListener(flash.Key);
  46. }
  47. }