Key.hx 1.6 KB

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