SO Answer / How to get Alt + C(or any other key) to work in JavaScript on Chrome for Mac and windows

See: http://stackoverflow.com/questions/14109639/how-to-get-alt-cor-any-other-key-to-work-in-javascript-on-chrome-for-mac-and

by KooiInc MeHere

HTML

<div id="result"></div>

JavaScript

window.onkeyup = function(e) {
    e = e || event;
    if(e.altKey)  {
        // alt-a, -b or -c (Note: IE doesn't support indexOf for Arrays)
        if (~[65,66,67].indexOf(e.keyCode)){
            log('(keyCode: '+e.keyCode+') alt-'+String.fromCharCode(e.keyCode)+' pressed');
        }
    }
}
    
function log(txt){
    var result = document.querySelector('#result')
    result.appendChild(document.createTextNode(txt));
    result.appendChild(document.createElement('br'));
    return true;
}