- From: Olli Pettay <Olli.Pettay@helsinki.fi>
- Date: Thu, 12 May 2011 18:00:11 +0300
- To: Giuseppe Pascale <giuseppep@opera.com>
- CC: "www-dom@w3.org" <www-dom@w3.org>
On 05/12/2011 05:53 PM, Giuseppe Pascale wrote: > On Thu, 12 May 2011 11:44:38 +0200, Olli Pettay > <Olli.Pettay@helsinki.fi> wrote: > >> On 05/12/2011 11:38 AM, Giuseppe Pascale wrote: >>> Hi all, >>> I was looking at DOM specifications and I'm a little bit confused about >>> the following. >>> >>> Question: (according to the spec) can an HTMLDocument receive a >>> keyup/down/press event? >>> >>> I say according to the spec, because this works in practice (tried in >>> Opera,Chrome and Firefox on Ubuntu) >>> >>> Anyway, if I look at the latest stable version of DOM 3 Events >>> http://www.w3.org/TR/DOM-Level-3-Events/ >> >> That is old. >> Use >> http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html >> Although even the latest draft has only Element as the target for key >> events. >> >> But anyway, do you have a testcase where events are targeted to >> document in all those browsers? >> (I think you're right, but I'd like to see what you were testing) >> > well I didn't try anything special, just something like this > > > <html> > <head> > <script type="text/javascript"> > > function testEvent(){ > document.onkeyup=my_keyup; > document.onkeydown=my_keydown; > document.onkeypress=my_keypress; > } > > function my_keyup(){ > alert('keyup'); > } > > function my_keydown(){ > alert('keydown'); > } > > function my_keypress(){ > alert('keypress'); > } > > </script> > </head> > <body onload="testEvent()"> > document.keyXXX event test > </body> > </html> > > Even though to be honest keyup event doesn't seem to be delivered (in > Opera, Chrome and FF). I didn't do any extensive testing with different > versions or OSes. > > /g I tried to come one with a testcase which might dispatch key events to document, but so far no luck. If all the elements are removed from document, key events aren't dispatched to document nor window, in gecko, webkit, opera - at least not in my testcase. So, so far the spec looks ok. -Olli
Received on Thursday, 12 May 2011 15:01:13 UTC