KeyboardEvent: keyCode deprecation hints have contradicting info wrt what to use instead #33694
Labels
Content:WebAPI
Web API docs
goal: consistency
(Experimental label) Issues about inconsistent/conflicting/contradictory content.
help wanted
If you know something about this topic, we would love your help!
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
What specific section or headline is this issue about?
What information was incorrect, unhelpful, or incomplete?
The page https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode recommends using
KeyboardEvent.code
instead of the deprecatedKeyboardEvent.keyCode
:But the overview page https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent recommends using
KeyboardEvent.key
in this section:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#:~:text=KeyboardEvent.keyCode
What did you expect to see?
I would expect both places to recommend the same approach to replacing the deprecated
keyCode
. Maybe it would be best to explain that usingkey
orcode
depends on the use case and give a very brief explanation of the difference between the two.But if only one alternative is suggested, I'd say that in a clear majority of cases
key
makes more sense.Do you have any supporting links, references, or citations?
https://blog.andri.co/022-should-i-use-ecode-or-ekey-when-handling-keyboard-events/
Nicely explains the (main?) difference between
key
andcode
Do you have anything more you want to share?
No response
The text was updated successfully, but these errors were encountered: