- From: Michael A. Puls II <shadow2531@gmail.com>
- Date: Sat, 14 Jan 2012 04:29:55 -0500
- To: www-dom@w3.org, "Hallvord R. M. Steen" <hallvord@opera.com>
On Tue, 03 Jan 2012 13:42:23 -0500, Hallvord R. M. Steen <hallvord@opera.com> wrote: > Hi, > quick question: if one presses ctrl+b, what should event.key and > event.char be set to for the B key's keydown and keyup events? > > I'm not off the top of my head certain whether the B key should cause a > keypress event here either. Spec text doesn't really say whether you > should take the state of other keys into account when determining > whether the key "normally" outputs a character: > > "A user agent must dispatch this event when a key is pressed down, if > and only if that key normally produces a character value" Not sure if it helps, but I tested with Firefox, Opera and Chrome with keyCode and charCode while pressing ctrl and b simultaneously: For 'keypress' and ctrl + b in a textarea: keyCode charCode Firefox 0 98 Opera 98 undefined Chrome 2 2 For 'keyup': Chrome: Two events: 66 0 and then 17 0 (in that order, no matter if b is held down first or not) Firefox: Sometimes one event of 66 0 and sometimes two events 66 0 and 17 0 (in that order, no matter if b is held down first or not) Opera: 66 undefined 17 undefined or 17 undefined 16 undefined depending on whether b was held down first first. For 'keydown': Firefox and Chrome: 17 0 66 0 or 66 0 17 0 depending on which key was pressed down first. Opera the same except undefined instead of 0. (IE doesn't fire events for ctrl + b in this case) -- Michael
Received on Saturday, 14 January 2012 09:30:43 UTC