On Apr 26, 2008, at 6:06 PM, Hallvord R. M. Steen wrote:
All keys except dead keys fire the hardware reference events. What
other events are fired depends on the type of key that is pressed
and response from the event listeners. Typically, alphanumerical
keys and punctuation keys fire text insertion events while control
keys and navigation keys do not. Dead keys may fire text insertion
events if pressed twice or followed by a space. The first time a
dead key is pressed fires no events at all.
This is strange, in Internet Explorer and Safari (haven't tested other
browsers), I'm observing a different behavior: pressing a dead key
does fire keydown/keyup. I was testing with a German keyboard layout,
pressing a key to the left from "1" (dead key for "^").
I also don't see any reason to avoid having the events fired.
However, different keyboard layouts change what OEM reference a
certain key has!
Ugh! Yes, I agree that this is probably too chaotic to specify or
emulate.
When a key is pressed, and the keydown event has been processed an
implementation must behave as if it implemented this algorithm when
firing keypress events:
* If the keypress follows a keydown event on the same key and the
earlier keydown event had its default action cancelled, terminate
this algorithm. [NOTE#1]
I think that this is a logical loop - since there is no keypress event
in existence yet, it cannot follow a keydown, or be otherwise referred
to :).
In my mental model, a keypress is a product of keydown default
handling, and not something directly caused by a physical keystroke.
It has been mentioned before that default handlers are out of scope
for DOM Events; not sure how to resolve this. Possibly, the event
could be specified by itself "in vacuum", and an informal note could
describe when it actually gets fired?
TODO: dead keys pressed twice fire two keypress events. Dead keys
followed by space fire keydown space, keypress for the dead key's
accent
Similarly, this is not necessarily something that the spec should
formally define - although dead key handling is very similar between
Mac and Windows (and presumably elsewhere), such details may not
remain unchanged forever. It's just that the OS-specific default
handler decides to fire two keypress events in some circumstances, etc.
- WBR, Alexey Proskuryakov