Skip to content

Commit 965a517

Browse files
committed
Opera seems to have stopped flipping ctrlKey and metaKey on OS X
And promptly broke CodeMirror in the process. Issue #1050
1 parent b45f94d commit 965a517

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/codemirror.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ window.CodeMirror = (function() {
626626
}, 50);
627627

628628
var name = keyNames[e_prop(e, "keyCode")], handled = false;
629-
var flipCtrlCmd = opera && mac;
630629
if (name == null || e.altGraphKey) return false;
631630
if (e_prop(e, "altKey")) name = "Alt-" + name;
632631
if (e_prop(e, flipCtrlCmd ? "metaKey" : "ctrlKey")) name = "Ctrl-" + name;
@@ -2286,12 +2285,18 @@ window.CodeMirror = (function() {
22862285
var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
22872286
var quirksMode = ie && document.documentMode == 5;
22882287
var webkit = /WebKit\//.test(navigator.userAgent);
2288+
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);
22892289
var chrome = /Chrome\//.test(navigator.userAgent);
22902290
var opera = /Opera\//.test(navigator.userAgent);
22912291
var safari = /Apple Computer/.test(navigator.vendor);
22922292
var khtml = /KHTML\//.test(navigator.userAgent);
22932293
var mac_geLion = /Mac OS X 10\D([7-9]|\d\d)\D/.test(navigator.userAgent);
22942294

2295+
var opera_version = opera && navigator.userAgent.match(/Version\/(\d*\.\d*)/);
2296+
if (opera_version) opera_version = Number(opera_version[1]);
2297+
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
2298+
var flipCtrlCmd = mac && (qtwebkit || opera && (opera_version == null || opera_version < 12.11));
2299+
22952300
// Utility functions for working with state. Exported because modes
22962301
// sometimes need to do this.
22972302
function copyState(mode, state) {

0 commit comments

Comments
 (0)