Skip to main content

Bug Tracker

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: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

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) {

	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

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.

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 dmethvin comment:3

owner: →
status: newpending

Are you saying that the browser gives you the right value but jQuery isn't returning it? If so your test case should show the value you expected.Also, you shouldn't be listening to keypress. See #7183 and #10172.

Changed January 04, 2014 07:52PM UTC by comment:4

status: pendingnew

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.


Changed January 04, 2014 08:04PM UTC by dmethvin comment:5

resolution: → duplicate
status: newclosed

Duplicate of #7183.Seems that way to me, I can reopen if not.