Module Dom_html.Keyboard_code

Use Keyboard_code when you want to identify a key that the user pressed. This should be invoked for keydown and keyup events, not keypress events.

If the browser supports the standardized key and code properties, then of_event on a keypress event will have the correct behavior. Otherwise, it might not identify or might mis-identify which key was pressed. This occurs because the keypress event is designed for printable characters while keydown and keyup are designed for physical keys. Thus, the older properties of keyEvent change behavior between keydown and keypress events. This change in behavior is what causes the mapping to be incorrect.

type t =
  1. | Unidentified
  2. | KeyA
  3. | KeyB
  4. | KeyC
  5. | KeyD
  6. | KeyE
  7. | KeyF
  8. | KeyG
  9. | KeyH
  10. | KeyI
  11. | KeyJ
  12. | KeyK
  13. | KeyL
  14. | KeyM
  15. | KeyN
  16. | KeyO
  17. | KeyP
  18. | KeyQ
  19. | KeyR
  20. | KeyS
  21. | KeyT
  22. | KeyU
  23. | KeyV
  24. | KeyW
  25. | KeyX
  26. | KeyY
  27. | KeyZ
  28. | Digit0
  29. | Digit1
  30. | Digit2
  31. | Digit3
  32. | Digit4
  33. | Digit5
  34. | Digit6
  35. | Digit7
  36. | Digit8
  37. | Digit9
  38. | Minus
  39. | Equal
  40. | Tab
  41. | Enter
  42. | Space
  43. | Escape
  44. | Backspace
  45. | Insert
  46. | Delete
  47. | CapsLock
  48. | BracketLeft
  49. | BracketRight
  50. | Semicolon
  51. | Quote
  52. | Backquote
  53. | Backslash
  54. | Comma
  55. | Period
  56. | Slash
  57. | F1
  58. | F2
  59. | F3
  60. | F4
  61. | F5
  62. | F6
  63. | F7
  64. | F8
  65. | F9
  66. | F10
  67. | F11
  68. | F12
  69. | Numpad0
  70. | Numpad1
  71. | Numpad2
  72. | Numpad3
  73. | Numpad4
  74. | Numpad5
  75. | Numpad6
  76. | Numpad7
  77. | Numpad8
  78. | Numpad9
  79. | NumpadMultiply
  80. | NumpadSubtract
  81. | NumpadAdd
  82. | NumpadDecimal
  83. | NumpadEqual
  84. | NumpadEnter
  85. | NumpadDivide
  86. | NumLock
  87. | ControlLeft
  88. | ControlRight
  89. | MetaLeft
  90. | MetaRight
  91. | ShiftLeft
  92. | ShiftRight
  93. | AltLeft
  94. | AltRight
  95. | ArrowLeft
  96. | ArrowRight
  97. | ArrowUp
  98. | ArrowDown
  99. | PageUp
  100. | PageDown
  101. | Home
  102. | End
  103. | VolumeMute
  104. | VolumeDown
  105. | VolumeUp
  106. | MediaTrackPrevious
  107. | MediaTrackNext
  108. | MediaPlayPause
  109. | MediaStop
  110. | ContextMenu
  111. | BrowserSearch
  112. | BrowserHome
  113. | BrowserFavorites
  114. | BrowserRefresh
  115. | BrowserStop
  116. | BrowserForward
  117. | BrowserBack
  118. | OSLeft
  119. | OSRight
  120. | ScrollLock
  121. | PrintScreen
  122. | IntlBackslash
  123. | IntlYen
  124. | Pause
val of_event : keyboardEvent Js.t -> t
val of_key_code : int -> t