I have a Javascript file that detects key codes, but it is set to react to Windows keyboard keys. How would I adapt it to work with a Mac keyboard?
The Alt key is the problem. I guess the Alt/Option key on a Mac keyboard is not the same as the Alt key for Windows. What name would I give to have that key recognized?
Code:
// Hotkeys
document.addEventListener('keydown', function(e){
if(e.shiftKey && !e.ctrlKey && e.altKey){
switch(e.keyCode){
// Edit styles with Alt+Shift+E
case 69: editStyles(); break;
// Unblock elements with Alt+Shift+U
case 85: unblockEle(); break;
// Block element with Alt+Shift+B
case 66: blockEle(); break;
// Unblock latest element with Alt+Shift+L
case 76: unblockEle(true); break;
// Block elements (don't use nth-child) with Alt+Shift+W
case 87: blockEle(true); break;
}
}
}, false);