Re: convertKeyIdentifier

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);

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 01:54:01 UTC