Skip to content

Instantly share code, notes, and snippets.

@v42
Created September 28, 2012 17:09
Show Gist options
  • Save v42/3801026 to your computer and use it in GitHub Desktop.
Save v42/3801026 to your computer and use it in GitHub Desktop.
Triforce Typing Detection in Javascript
/*
*  ▲
* ▲ ▲
*
* Newfags can't triforce.
*
* TODO: detect on mac (white triangles) and test detection on linux
*/
var kpr = [],
kcw = ['160','160','9650','13','9650','160','9650'];
function pushKey(k){
if(kcw[kpr.length] && kcw[kpr.length].toString()==k){
kpr.push(k);
if(kpr.length === kcw.length){
alert(' ▲\n▲ ▲\nTriforce111!!11!!ONEONE!1');
}
} else {
kpr = [];
}
//console.log(kpr);
}
window.addEventListener("keypress", function(e){
pushKey(e.keyCode.toString());
}, true);
@v42
Copy link
Author

v42 commented Oct 22, 2012

// for song of time instead... also... change the listener to keyup instead
kcw = ['39','65','40','39','65','40'];

@v42
Copy link
Author

v42 commented Nov 28, 2013

//Konami Code! :D
kcw = ['38', '38', '40', '40', '37', '39', '37', '39', '66', '65'];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment