W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2013

Re: DOM Keyboard Event Level 3 questions about proposal

From: Егор Николаев <termi1uc1@gmail.com>
Date: Mon, 11 Mar 2013 18:58:27 +0400
Message-ID: <CAP=KyTjN_k-sc4JBpn0EqMM=jwc9KqkBxPA+V_PHvtHkLchsBQ@mail.gmail.com>
To: Florian Bösch <pyalot@gmail.com>, "www-dom@w3.org" <www-dom@w3.org>
> But why the "code" values is so complicated?
>> For example: event.code='ShiftLeft'. If I need to detect the exactly
>> 'Shift' key, I can read 'location' property.
> The location property designates things such as numpad, function row,
> center keys, I don't think shift left and right would have a different
> location (I could be wrong though).

>  In the most common scenarios I need to detect just 'Shift' key without
>> exactly location.
> Yeah, but you wouldn't want to throw away the possibility of identifying
> left or right. Therefore it's not the same.

The key activated originated from the left key location (there is more than
one possible location for this key).
Example: the left 'Control' key on a PC 101 Key US keyboard.
The key activation originated from the right key location (there is more
than one possible location for this key).
Example: the right 'Shift' key on a PC 101 Key US keyboard." (from spec).

You can check "location" values in IE9+ or in Opera 12+ for "Shift" keys.
So for left "Shift" location would be DOM_KEY_LOCATION_LEFT, for right

>> Another example is event.code="Digit2". While I can understand
>> "ShiftLeft" value - it brings additional information, I can't understand
>> the "Digit"/"Key" prefix. There is no other "2" value in the spec, no need
>> to do the "code" values so complicated. Why can't it be just "2" as well as
>> "KeyA" be just "A"?
> Because they're not "2" or "A", they might be  "ش" or "١" or "た". The
> name is choosen to designate that you're not dealing with alphanumerics
> here, but with key identifiers.
I don't see much differences between "KeyA" and "A" except of complication
of js-code writing. When the js-developer using "code" property he should
know that it's mean and that values it can contains. "Key"/"Digit" prefix
is useless and redundant, and requires to write more code. In "code"
property the "A" value can serve as unique key as well as "KeyA" value.
Received on Monday, 11 March 2013 14:58:54 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC