keyboardEvents.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Gather the list of keyboard event types as constants.
  3. */
  4. export class KeyboardEventTypes {
  5. /**
  6. * The keydown event is fired when a key becomes active (pressed).
  7. */
  8. public static readonly KEYDOWN = 0x01;
  9. /**
  10. * The keyup event is fired when a key has been released.
  11. */
  12. public static readonly KEYUP = 0x02;
  13. }
  14. /**
  15. * This class is used to store keyboard related info for the onKeyboardObservable event.
  16. */
  17. export class KeyboardInfo {
  18. /**
  19. * Instantiates a new keyboard info.
  20. * This class is used to store keyboard related info for the onKeyboardObservable event.
  21. * @param type Defines the type of event (KeyboardEventTypes)
  22. * @param event Defines the related dom event
  23. */
  24. constructor(
  25. /**
  26. * Defines the type of event (KeyboardEventTypes)
  27. */
  28. public type: number,
  29. /**
  30. * Defines the related dom event
  31. */
  32. public event: KeyboardEvent) {
  33. }
  34. }
  35. /**
  36. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  37. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  38. */
  39. export class KeyboardInfoPre extends KeyboardInfo {
  40. /**
  41. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  42. */
  43. public skipOnPointerObservable: boolean;
  44. /**
  45. * Instantiates a new keyboard pre info.
  46. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  47. * @param type Defines the type of event (KeyboardEventTypes)
  48. * @param event Defines the related dom event
  49. */
  50. constructor(
  51. /**
  52. * Defines the type of event (KeyboardEventTypes)
  53. */
  54. public type: number,
  55. /**
  56. * Defines the related dom event
  57. */
  58. public event: KeyboardEvent) {
  59. super(type, event);
  60. this.skipOnPointerObservable = false;
  61. }
  62. }