On Sun, Mar 10, 2013 at 8:48 PM, Егор Николаев <termi1uc1@gmail.com> wrote:
> 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.
> 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.
But this is just my first impressions. I think I need to create another
> thread to discuss this or could anyone tell me the link/name of "code"
> property discussing thread if it exists?
>
The Event Level 4 specification on keyboard events contains a variety of
key layout tables for different keyboard layouts.