Closed Bug 1194586 Opened 9 years ago Closed 7 years ago

keypress event is firing for non character producing key combinations

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

39 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 968056

People

(Reporter: bijaya.k.dash, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150630154324

Steps to reproduce:

I have an onkeypress event listener for a input of type text. As per the documentation on https://developer.mozilla.org/en-US/docs/Web/Events/keypress key press is only fired when a key is pressed and produces a character value. But if I press ctrl+A to select all it still fires the key press event. 


Actual results:

Key press event is fired for non character producing events like ctrl+A. Its even firing for F5.


Expected results:

As per the documentation on https://developer.mozilla.org/en-US/docs/Web/Events/keypress it should not fire keypress for non character producing events like ctrl+A, F5.
Component: Untriaged → Keyboard Navigation
Component: Keyboard Navigation → Event Handling
Product: Firefox → Core
Still a problem in Firefox 43.0.4 (Windows 7 64 Bit)

Not only does Firefox fire keypress-events for non-character keys like the cursor keys or when tabbing out of focus, they are also responsible for the default action of those keys, i.e when preventing the default of all keypress events, you can no longer move the caret in an input field.

A simple example can be seen here: https://jsfiddle.net/g2bjb2sg/

In Firefox, you cannot move the caret in the input field, even though keydown is completely untouched.

I also tested this in Chrome Version 47.0.2526.106 and IE 11.0.9600.18124. Both of them allow to move the caret, delete characters, ctrl+a, etc. Firefox allows none of this.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.