I am using prototype to trap the return-key-in-text-fields and prevent it from submitting the form.
This works in all browsers except Safari, for both "return" and "enter" keys:
if (e.element().type === 'text' && e.keyCode === Event.KEY_RETURN)
Safari is sending keyCode of 3 for the enter key, so you have to do:
if (e.element().type === 'text' && (e.keyCode === Event.KEY_RETURN
e.keyCode === 3))
After reading the prototype docs here regarding keys:
http://www.prototypejs.org/api/event
I would expect that it normalizes those keys into the same thing, but hey, maybe I shouldn't expect that. I expected it since there is no KEY_ENTER, and it kinda sounds like that's what the keycode normalization is supposed to do...
In any case, I thought I'd report it. This issue *may* be related to some Autocomplete bugs that I saw while searching for dupes before posting this.
This was tested with Prototype 1.6.
Attachments
Change History
Download in other formats:
|