Affecting Non-printable keys will soon stop firing keypress event

Published: | Categories: DOM

Description

In order to follow the UI Events spec and other browsers’ behaviour, Firefox will stop dispatching the keypress event for non-printable keys and key combinations in the near future.

Non-printable keys are function keys like Home, End, Tab, Escape, Backspace, Page Down, arrows, etc. Non-printable key combinations include Ctrl+A, Alt+G, Command+Shift+M and so on. Web developers should be using the keydown event instead to handle those keys.

An exception is the Enter key; pressing Enter with no modifiers, Shift+Enter or Ctrl+Enter will fire the keypress event as before, which is invalid in the current spec but compatible with other browsers.

This change has been made to the Nightly and early Beta/DevEdition channels as of Firefox 60. Other channels will also adopt the standard-compliant behaviour once compatibility issues on major sites are solved. Currently, some keyboard shortcuts on Gmail, Google Docs and Google Sheets are known to be broken.

Update: The change, originally requested by Google, has been temporarily backed out to give Google engineers time to fix the issue in their apps.

Update 2: This change has been landed again at Firefox 61 Nightly but disabled for now on Gmail, Google Docs, Google Sheets and Google Slides to avoid any breakage.

Update 3: Dropbox Paper, Google Hangouts, Google Inbox, Google Keep and Remember The Milk as well as major public Etherpad instances have also been added to the blacklist so those developers have extra time to fix the issue.

If you’re a developer of one of those apps who would like to test the new behaviour, you have to override the blacklist with the browser’s configuration editor: open about:config in Firefox, search dom.keyboardevent.keypress.hack.dispatch_non_printable_keys, click on it, empty the value, then click OK.

References