Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyboardEvent.keyCode Deprecated #1350

Open
Zauberbutter opened this issue Mar 9, 2020 · 2 comments
Open

KeyboardEvent.keyCode Deprecated #1350

Zauberbutter opened this issue Mar 9, 2020 · 2 comments

Comments

@Zauberbutter
Copy link

Zauberbutter commented Mar 9, 2020

Because of the deprecation of keyCode should the KeyboardEvent.code attribute not be supported? See the keyCode search results.

@carmacleod
Copy link
Contributor

Agree we should replace uses of KeyboardEvent.keyCode and KeyboardEvent.which to keep current, particularly now that the latest Edge supports the newer api.

Note that we will need to use KeyboardEvent.key to look for non-printable keys like arrows and escape (not KeyboardEvent.code).

Here are the KeyboardEvent.key values that we will typically need (note that they are strings):

  • "ArrowDown"
  • "ArrowLeft"
  • "ArrowRight"
  • "ArrowUp"
  • "Home"
  • "End"
  • "PageUp"
  • "PageDown"
  • "Enter"
  • "Tab"
  • "Escape"
  • " " (for space key)

We can still use KeyboardEvent.ctrlKey, altKey, shiftKey and metaKey to check for modifiers.

We may want to do something like the following to be sure we work in older browsers?

var key = event.key || event.keyCode;
if (key === 'Escape' || key === 'Esc' || key === this.keyCode.ESC /* 27 */) { ... }

@css-meeting-bot
Copy link
Member

css-meeting-bot commented Apr 14, 2020

The ARIA Authoring Practices (APG) Task Force just discussed keyCode Deprecation.

The full IRC log of that discussion <carmacleod> TOPIC: keyCode Deprecation
<carmacleod> github: https://github.com//issues/1350
<carmacleod> mck: should we add this to our code guide?
<carmacleod> Jemma: good idea

Also, Jon mentioned that we should not have common "util" methods for these, because we want each example to be self-contained and self-explanatory, so we don't want stuff hiding in util methods. Folks agreed that "no utils" is best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants