This should go in lighthouse.
On Fri, Dec 3, 2010 at 1:05 PM, xtof <[email protected]> wrote:
> Hello everyone,
>
> is this a bug or a feature ?
>
> $('someinputfield').addEvent("keypress",function(event)
> { alert(event.key); });
>
> press "(". The alert will prompt "down".
>
> Both "(" and ↓ (down arrow) have a key code 40, one is virtual
> the second is unicode.
>
> Mootools does not fire "keypress" on special keys excepted "Enter".
> But in the code,
> the special keys (Event.Keys) detection is always done, even in case
> of keypress.
>
> A quick fix on the Event object (at the beginning) :
>
> var Event = new Type('Event', function(event, win){
>
> (...)
>
> if (type.indexOf('key') != -1){
> var code = event.which || event.keyCode;
> var key = Object.keyOf(Event.Keys, code);
> if(key!='enter' && type=='keypress') key=null; /* fix for
> special
> keys */
> if (type == 'keydown'){
> var fKey = code - 111;
> if (fKey > 0 && fKey < 13) key = 'f' + fKey;
> }
> if (!key) key = String.fromCharCode(code).toLowerCase();
> }
> (...)
>
> I'm not sure this fix could have side effects...
>
> Sadly, Mootools keeps the charCode inside Event.event.charCode, and
> I'm nut sure it's well supported on all browsers.
>
> Any comment will be grealty appreciated.
>
> Christophe.
>