KeysDown array

by Darby Rathbone

HTML

press any keys and then press alt+tab then relase after the window changes and see what keys are down or just any keys and then tab

JavaScript

var keys = document.createElement('div'),
    k = [];
document.body.appendChild(keys);
addEventListener('keydown',function(e){

    if(!k[e.which])
    {
            console.dir(e);
    k[e.which] = e.timeStamp;
            console.log(k);
    }


})
addEventListener('keyup',function(e){
    delete k[e.which];

})
addEventListener('blur',function(e){
    k = [];
});
var keyValueSwap = function(e,i){if(e){return i;}return e;};
requestAnimationFrame(function anim(){
    keys.innerHTML = k.map(keyValueSwap).filter(Boolean).join(" ").trim();
    requestAnimationFrame(anim);
})