W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2012

DOM Keyboard Event Level 3 questions about proposal

From: Егор Николаев <termi1uc1@gmail.com>
Date: Wed, 26 Sep 2012 13:09:20 +0400
Message-ID: <CAP=KyTgtHnSB9_5sEdzH40-SZ2UmvpHQALRTDF7+ddJ5z8bSOg@mail.gmail.com>
To: www-dom@w3.org
Hello.

Right now I'm looking for a way to implement 'DOM keyboard  event level 3'
into my current project and also I'm developing polyfill for this API (
https://github.com/termi/DOM-Keyboard-Event-Level-3-polyfill). As a
reference I've used this standard (
http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120614/) along with Opera
12.10 and IE9+ implementations.

I've a few questions:

1) How can I determine key combination triggering if user's locale is other
than US_en? Both 'char' and 'key' properties return the symbol, that's
specific to current user's locale. For example how can we detect 'Ctrl+S'
combination? With this code:

if(event.key.toLowerCase() == 's' || event.key.toLowerCase() == 'ы' || ...
[and so on for every locale that is supported by your web application.]


2) There's no clear statement about 'char' and 'key' values for special
symbol key press events. Opera 12.10 x64 Win7x64  (12.10.1592 at least),
for example, returns some gibberish in key and char property while Ctrl key
pressed. You can see it for yourself by going to
http://h123.ru/-/tests/KeyboardEvent/ with Opera 12.10 beta RC and pressing
Ctrl+Q (or Ctrl+<any character>).


3) Why the 'key' property is case-sensitive if we already have 'char'
property for input symbol detection.



To summarize I'd like to say that the new API doesn't solve any of the
problems but creating new ones. Especially after cross-locales 'keyCode'
property has been declared outdated.



As a solution I'd like to suggest 'char' and 'key' logical division. 'Char'
property should return input symbol (just like it does right now) and 'key'
property should always, for any special symbol key pressed, return
lowercased US_en locale symbol for any symbol value. For example it can be:
event :{
  key : "q"
  , char "Й"
  , shiftKey : true
  , locale : "RU_ru"
  , ...
}
Received on Wednesday, 26 September 2012 11:17:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 26 September 2012 11:17:53 GMT