← Back to team overview

jessyink-team team mailing list archive

Re: key handling again...

 

Hey Team,

I had a look at key events for the past hour, and across browsers,
things look really messed-up.

http://ejohn.org/blog/keypress-in-safari-31/
http://unixpapa.com/js/key.html

I'm not even sure what I took back from reading all this. Was webkit's
decision of not sending special characters via keypress justified?
keypress is bad? use keydown instead? how can I find the ascii value
of the key then... all very confusing. Like the example given, nothing
garanties (with keydown) that when you press SHIFT + 4, it'll be the $
sign character you expect.

Some people do this:
http://dev.rubyonrails.org/attachment/ticket/9666/event_keypress.diff
if (eventName == 'keypress' && Prototype.Browser.WebKit) return "keydown";

But then some people say you shouldn't.
http://github.com/sstephenson/prototype/blob/bfd5353cbfa8b344d959d28c4e0cc86cda61cbc4/src/event.js

The above from prototypejs seems to be the best solution by the way...
if I'm not mistaken.

Anything we can lift from there? I'll keep working at it as proper
(cross-browser) key handling in JessyInk is pretty much critical...
especially with the "custom keys" targeted for release 1.3........

Cheers,
Egor

On Sun, Jun 7, 2009 at 9:54 AM, Egor Zindy<ezindy@xxxxxxxxx> wrote:
> OK, I need to see how this is handled in other projects...
>
> I thought a
>
> var charKey = e.charCode || e.keyCode;
>
> would suffice, but obviously not for webkit based browsers.
>
> From http://lists.macosforge.org/pipermail/webkit-dev/2007-December/002992.html
>
>   Here is a list of changes that were made since Safari 3 release
> with Mac OS X 10.5 Leopard:
>
> - Arrow keys no longer result in keypress events.
>    These do not correspond to characters, and are now processed in
> keydown default event handler.
>



Follow ups

References