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

Re: convertKeyIdentifier

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Wed, 23 Sep 2009 19:50:34 +0300
Message-ID: <4ABA51DA.9080003@helsinki.fi>
To: Maciej Stachowiak <mjs@apple.com>
CC: Anne van Kesteren <annevk@opera.com>, Doug Schepers <schepers@w3.org>, "www-dom@w3.org" <www-dom@w3.org>
On 9/23/09 4:53 AM, Maciej Stachowiak wrote:
>
> On Sep 22, 2009, at 9:27 AM, Anne van Kesteren wrote:
>
>>
>>
>>> this is a directly related to DOM3 Events key identifiers, and it
>>> needs to be implemented in that context. Mozilla and Microsoft have
>>> already agreed that we need this, BTW.
>>
>> Well, I disagree. I do not see the point in having this method as I do
>> not see the need for having multiple representations for everything in
>> the first place in the context of DOM Level 3 Events.
>>
>> Furthermore I think putting createEvent on Document was a mistake in
>> to begin with. Especially with the design we have now where DOM events
>> are often used outside the context of documents. (Think of e.g. Web
>> Workers.)
>
> I agree with Anne. I think we should remove the U+XXXX format entirely.
> If you have a string like Q, you can convert it to a unicode numeric
> value for range checking like this:
>
> var codePoint = evt.keyIdentifier.charCodeAt(0);

If I haven't mistaken,
charCodeAt(0) isn't quite enough. It returns values between
0-65536. One needs to check also charCodeAt(1).
A helper method to get the codepoint easily in all cases could be useful.

-Olli

>
> This seems easier than this as a way to get a numeric unicode code point:
> parseInt(document.convertKeyIdentifier(evt.keyIdentifier).substring(2))
>
> Also, you can range check the actual string, so it's rare to need the
> code point at all:
> if (evt.keyIdentifier >= "A" && evt.keyIdentifier <= "Z")
>
> I don't think the U+XXXX string format does not add any value.
>
> Regards,
> Maciej
>
>
>
Received on Wednesday, 23 September 2009 16:51:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:03 GMT