Side navigation
#14669 closed bug (duplicate)
Opened January 03, 2014 09:34PM UTC
Closed January 04, 2014 08:04PM UTC
event.which failing for Shift + 7 (&) as Code 38 (Up Arrow)
Reported by: | jon.hartmann@gmail.com | Owned by: | jon.hartmann@gmail.com |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I have a simple batch of code that prevents up/down/tab/enter on a field:
if ($.inArray(event.which, [9, 38, 40, 13]) > -1) { event.preventDefault(); return false; }
However, if I type something like "example&" the code fires went I hit "&". If I put a break in there I can see that the event.which says its 38, and the other attributes of the event agree.
If I do other special characters such as ^ or *, nothing happens, and if I hit the up arrow, the code fires as expected saying that it too is "38"
Attachments (0)
Change History (5)
Changed January 03, 2014 09:35PM UTC by comment:1
Changed January 03, 2014 09:47PM UTC by comment:2
Example inJSFiddle:
You can verify the problem there; I had a moment of panic where I thought the problem might be more complex than this.
Changed January 03, 2014 10:55PM UTC by comment:3
Changed January 04, 2014 07:52PM UTC by comment:4
status: | pending → new |
---|
You are right that it is the keypress event that is throwing the odd code. Weird... I'll review Monday and update if just removing keypress from this listener resolves this issue; I'm certain there was a reason why keypress was originally added since its common to avoid it.
Thanks!
I've tested this in Chrome 31 and a recent FF with the same result. Running on a Windows 7 box... not sure what else would be relevant.