Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11328 closed bug (fixed)

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

Reported by: Alexey Lebedev <helloalisey@…> Owned by: Alexey Lebedev <helloalisey@…>
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: http://jsfiddle.net/ubfMJ/

Change History (5)

comment:1 Changed 11 years ago by dmethvin

Owner: set to Alexey Lebedev <helloalisey@…>
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.

comment:2 Changed 11 years ago by Alexey Lebedev <helloalisey@…>

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

comment:3 Changed 11 years ago by dmethvin

Component: unfiledevent
Milestone: None1.8
Priority: undecidedlow
Status: newopen

comment:4 Changed 11 years ago by dmethvin

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.

comment:5 Changed 11 years ago by Dave Methvin

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

Note: See TracTickets for help on using tickets.