Skip to main content

Bug Tracker

Side navigation

#11328 closed bug (fixed)

Opened February 11, 2012 04:03PM UTC

Closed June 11, 2012 10:53PM UTC

Ctrl key doesn't set event.metaKey to true on Windows

Reported by: Alexey Lebedev <> Owned by: Alexey Lebedev <>
Priority: low Milestone: 1.8
Component: event Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

#3368 was supposed to remove mapping of Ctrl key to event.metaKey on Mac platform, but it also removed this mapping on Windows (tested on Windows 7 and XP SP3). jQuery 1.6.4 sets event.metaKey to true when you hold Ctrl, but jQuery 1.7.1 does so only in IE6-8. In IE9, Chrome 16, Firefox 10 and Opera 11.6 it always sets metaKey to false.

See the demonstration:

Attachments (0)
Change History (5)

Changed February 11, 2012 04:50PM UTC by dmethvin comment:1

owner: → Alexey Lebedev <>
status: newpending

This is one of the reasons #3368 took so long to address. There is no perfect resolution. What key do you press on a Windows keyboard to get Meta?

So is the bug you're reporting that IE6-8 return metaKey=true when Ctrl is held down? By the title it sounds like you're asking for #3368 to be reverted.

Changed February 11, 2012 06:21PM UTC by Alexey Lebedev <> comment:2

status: pendingnew
What key do you press on a Windows keyboard to get Meta?

I press Ctrl, which translated to e.metaKey before 1.7 release.

As I understand, #3368 was proposed as Mac-only enhancement to make it easier to tell apart Ctrl and Cmd, which is a good idea. But this have never been a problem on Windows, which doesn't have Cmd key. Even if you connect an Apple keyboard, Cmd maps to Win key. So I think that #3368 wasn't meant to change how event.metaKey works on Windows.

W3C spec is not clear about what 'Meta Key' means, while vendors seem to agree that Ctrl and Meta are different things. At the very least jQuery event.metaKey should work in a consistent manner in all browsers on Windows.

I would be happy with any of these anlernatives:

a) map .ctrlKey -> .metaKey on Windows, but keep them separate on Mac (not sure how to accomplish this without UA sniffing)

b) never map .ctrlKey to .metaKey; as simple as changing this check to

event.metaKey = !!event.metaKey

Changed March 10, 2012 02:04PM UTC by dmethvin comment:3

component: unfiledevent
milestone: None1.8
priority: undecidedlow
status: newopen

Changed June 11, 2012 10:40PM UTC by dmethvin comment:4

Since we're only talking about IE 6/7/8 I think option B is probably best. We don't have a way to detect the platform short of the tea leaves contained in userAgent.

Changed June 11, 2012 10:53PM UTC by Dave Methvin comment:5

resolution: → fixed
status: openclosed

Fix #11328. I've never metaKey I liked on IE 6/7/8.

The event.metaKey property is undefined there so we ensure it's set to false for lack of a better default. The originalEvent.metaKey property is untouched if you prefer to make other guesses about the platform or key state.

This is pretty much impossible to unit test since it is not only platform dependendent but also only executed for native browser events.

Changeset: f8c02c886efdf3e42819a960da28738e20bb7a48