Skip to content

Commit 039716d

Browse files
authored
Merge pull request #2389 from Danziger/patch-1
Add information about virtual/mobile keyboards and an additional keyboard event inspection tool.
2 parents 4a0da59 + 04b1313 commit 039716d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

2-ui/3-event-details/7-keyboard-events/article.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ In the past, there was a `keypress` event, and also `keyCode`, `charCode`, `whic
170170

171171
There were so many browser incompatibilities while working with them, that developers of the specification had no way, other than deprecating all of them and creating new, modern events (described above in this chapter). The old code still works, as browsers keep supporting them, but there's totally no need to use those any more.
172172

173+
## Mobile Keyboards
174+
175+
When using virtual/mobile keyboards, formally known as IME (Input-Method Editor), the W3C standard states that a KeyboardEvent's [`e.keyCode` should be `229`](https://www.w3.org/TR/uievents/#determine-keydown-keyup-keyCode) and [`e.key` should be `"Unidentified"`](https://www.w3.org/TR/uievents-key/#key-attr-values).
176+
177+
While some of these keyboards might still use the right values for `e.key`, `e.code`, `e.keyCode`... when pressing certain keys such as arrows or backspace, there's no guarantee, so your keyboard logic might not always work on mobile devices.
178+
173179
## Summary
174180

175181
Pressing a key always generates a keyboard event, be it symbol keys or special keys like `key:Shift` or `key:Ctrl` and so on. The only exception is `key:Fn` key that sometimes presents on a laptop keyboard. There's no keyboard event for it, because it's often implemented on lower level than OS.

0 commit comments

Comments
 (0)