Re: Replacing the event keyCode value.

On , Aryeh Gregor <ayg@aryeh.name> wrote:

> On Wed, Nov 23, 2011 at 9:00 AM, Olli Pettay <Olli.Pettay@helsinki.fi>  
> wrote:
>> Replace the value of keyCode in which way?
>> Could you give an example what used to work and what doesn't work
>> anymore. Also, note that Internet Explorer didn't support DOM events
>> before IE9, although other browsers did.
>
> Links to the discussions you found would be useful too.
>

IE allows the keyCode property in the event object to be assigned, like

# if (event.keyCode == 27) event.keyCode = 13;

and with a special quirk, assigning 0 prevents the event.

This is Microsoft's proprietary behavior, and if that is a serious  
interoperability issue, then you should use the X-UA-Compatible header or  
meta tag, or Microsft could allow keyCode to be writable from event  
listeners registered using attachEvent.

Anyway, not a specification issue. The specification has been like this  
since ever.

Received on Friday, 2 December 2011 00:54:18 UTC