Created
September 10, 2014 16:42
-
-
Save nmccready/fd853479d373954138f5 to your computer and use it in GitHub Desktop.
Code fixes to make chrome keyboard tab ordering shortcuts work on OSX.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.appVersion.indexOf("Linux") < 0) { | |
document.addEventListener("keydown", function(e) { | |
// return if no modifiers. | |
// if (!e.shiftKey || !e.ctrlKey) { | |
// return; | |
// } | |
if (!e.metaKey || !e.shiftKey) { | |
return; | |
} | |
// Only send if we are interested. | |
switch (e.keyCode) { | |
// Pgup/dn | |
case 33: | |
case 34: | |
// 0..9 | |
case 48: | |
case 49: | |
case 50: | |
case 51: | |
case 52: | |
case 53: | |
case 54: | |
case 55: | |
case 56: | |
case 57: | |
chrome.extension.sendMessage( | |
{keyCode: e.keyCode}, | |
function(response) { | |
// No-op. | |
}); | |
e.stopPropagation(); | |
e.preventDefault(); | |
break; | |
} | |
}, | |
true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment