RE: DOM Level 3 KeyboardEvent

Hi Wez,

Responses inline.

Thanks,

Jacob


> From: Wez <wez@chromium.org>
> Date: Thu, 17 Mar 2011 21:19:22 +0000
> Message-ID: <AANLkTikBJRm1825m+dkFf_G2xjbhadypBP1-=fAq=3OY@mail.gmail.com>
> To: www-dom@w3.org
> Hi,
>  
> I've got a couple of questions about the DOM Level 3 Events draft
> specification for KeyboardEvent:
>  
> 1.  The KeyboardEvent's "key" field contains a "key value", which reflects
> the meaning of the key taking into account the current keyboard layout,
> modifiers and other context, as I understand it, so that Shift+A gives
> "U+0041" but A alone gives "U+0061".  Is that correct?  What should a key
> produce if it has neither a character nor a function associated with it in a
> given context?
>
Correct, key takes into account modifiers and location. However, there are some circumstances where a key produces a character, but it's key value differs from the character produced. Examples include the spacebar (key: 'Spacebar', char: \u0020) or the add key (key: "Add", char: \u002B). See the Key Values Set for more info. [1]

When the key does not have an entry in the key values set, then you should provide the Unicode string of the character value produced (again, taking into account modifiers, etc.).

A set of values for function keys is provided in the key values set as well. For function keys which do not have an entry in this list, the UA may devise a value using the constraints defined in the key value algorithm. [2]

I'm not aware of keys which are neither character or function keys. Can you provide an example? My assumption is that non-character producing keys are always function keys (not to be confused with F1-F10 only).

> 2.  The "key" field is specified such that it can express keys with code
> points only from Unicode's Basic Multiligual Plane, which I gather is for
> ECMAScript conformance.  Is the intent to use UTF-16 surrogates for these,
> as is mention in the doc, in which case an application will see multiple
> KeyDown events for a single actual event, or could KeyDown and KeyUp support
> ECMAScript friendly key-identifier strings for BMP, and longer strings for
> characters outside that?
>  

I believe the idea is to include UTF-16 surrogates pairs in a single event (the example cited in the spec is \uD84E\uDDC2). This should be ECMAScript friendly and avoid multiple events. But I'm not the best expert in this area. Perhaps Doug can comment here. I'll also check what we do in IE9.

> 3.  It seems that the only way for KeyUp to work is for the key-identifier
> it provides to match the one specified in the KeyDown that the key
> originally triggered, rather than reflecting whatever symbol the key would
> produce under the current modifiers - is that correct?  e.g. the squence
> Shift-down, a-down, Shift-up, a-up should give "U+0041" as the
> key-identifier for both a-down and a-up?  (BTW, the text for "keyup" seems
> to be a straight copy of that for "keyup" in the draft)
>  

I believe the copy/paste error for keyup was fixed in one of my recent changes. Let me know if I missed something.

No, keyup will not necessarily match keydown. This is critical because the state of modifiers can change in between these events (like in your example). Some applications care what the key value was at down, others at up--so it's important that the key value reflect the state when the key went down or up. I don't see why it would be a requirement that they match--in fact, it would be a farce to report "A" for the keyup in your example as that does not reflect the key value when the key came up.

In your example, the keydown would be "A" and the keyup would be "a". 

> Thanks,
>  
> Wez
>  
>  
> From: wez@google.com [mailto:wez@google.com] On Behalf Of Wez
> Sent: Tuesday, April 05, 2011 2:48 AM
> To: Jacob Rossi
> Subject: Re: New edits to DOM L3 Events
>  
> Hi Jacob,
>  
> I've got a question about the "key" field and the "key value" it contains, which I asked on www-dom last month, but didn't get any response on - would you mind giving me your opinion?
>  
> Thanks,
>  
> Wez
>  
> On 31 March 2011 02:03, Jacob Rossi <jrossi@microsoft.com> wrote:
> Hey folks,
>  
> As a heads up, Doug Schepers has asked me to assist with editing the DOM3 Events spec since he's a rockstar and working on so much these days! So in the coming weeks, he and I will be going through the various outstanding issues. Most of these are editorial in nature. But I appreciate any feedback to the changes.
>  
> Thanks,
>  
> Jacob Rossi [MSFT]
>  

Received on Thursday, 7 April 2011 01:28:52 UTC