Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17864 closed defect (wontfix)

dojo/on keypress does not fire for non-visible characters in IE11, Chrome

Reported by: Frank Fortson Owned by:
Priority: undecided Milestone: tbd
Component: Events Version: 1.9.3
Keywords: Cc:
Blocked By: Blocking:

Description

An event handler for the "keypress" event for an input element attached via dojo/on does not fire for non-visible characters, e.g., backspace, when using the IE11 and Google Chrome (current) browsers. It does fire for the Firefox (current) browser.

dojo.connect does fire for the keypress event for non-visible characters in the same browsers.

Test Case: dojo/tests/on/connectKey.html

Comment out and replace this line to remove the other events and leave only the keypress event.

// on(dom.byId("textbox"), "keypress, keydown, compositionend", function(evt){
on(dom.byId("textbox"), "keypress", function(evt){ // handle only the keypress event.

Comment out these lines so that the input box will display visible characters.

// evt.preventDefault();  // commented to permit input box to display text.
// evt.stopPropagation();  // commented to permit input box to display text.

View the browser console. Type one or more visible characters in the input box. They should display, and the console should log the event being fired, e.g.,

keypress keyCode = 97 charCode = 97

Type the backspace key. The character is erased from the input box, but the console does not log the event being fired.

Change History (4)

comment:1 Changed 6 years ago by bill

Component: CoreEvents
Resolution: wontfix
Status: newclosed

This is intended behavior. You should use keydown for non-visible characters, and keypress for visible characters. dojo/on intentionally does not do the normalization that dojo.connect() did.

Note that IE and Chrome's behavior is standard, and firefox is non-standard. That's why dojo/on does not try to normalize IE and Chrome to be like FF.

comment:2 Changed 6 years ago by Frank Fortson

Ok, the documentation probably needs changing as it shows examples with keypress for non-visible characters. We'll just use keyup, as we need to react to both visible and non-visible characters, e.g., backspace, in an input field. keypress fires both (keydown, then keypress). keyup works. Just seems strange for a keypress event to not fire for a non-visible character.

comment:3 Changed 6 years ago by bill

I'm sure the documentation can be improved although I'm not sure which part you are referring to exactly. If you have some improvements (to https://github.com/dojo/docs) it would be great if you could submit them as pull requests.

Note that keypress and keydown are documented at http://dojotoolkit.org/reference-guide/1.9/quickstart/events.html though (also in the above github repository).

comment:4 Changed 6 years ago by Frank Fortson

Ok, I'll try to get time to make the changes, if I have the permissions, especially on the example code that can be "Run" on the pages.

http://dojotoolkit.org/reference-guide/1.9/dojo/keys.html

Note: See TracTickets for help on using tickets.