Last active
October 5, 2015 01:54
-
-
Save euharrison/a170a6cd1e221205e523 to your computer and use it in GitHub Desktop.
arrows key to calibrate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var values = [0,0,0,0]; | |
document.addEventListener('keydown', function(e) { | |
if (!e.ctrlKey && !e.altKey && !e.shiftKey) { | |
switch (e.which) { | |
case 38: values[0]++; e.preventDefault(); break; //right | |
case 39: values[0]++; e.preventDefault(); break; //up | |
case 37: values[0]--; e.preventDefault(); break; //left | |
case 40: values[0]--; e.preventDefault(); break; //down | |
} | |
} | |
if (e.ctrlKey) { | |
switch (e.which) { | |
case 38: values[1]++; e.preventDefault(); break; | |
case 39: values[1]++; e.preventDefault(); break; | |
case 37: values[1]--; e.preventDefault(); break; | |
case 40: values[1]--; e.preventDefault(); break; | |
} | |
} | |
if (e.shiftKey) { | |
switch (e.which) { | |
case 38: values[2]++; e.preventDefault(); break; | |
case 39: values[2]++; e.preventDefault(); break; | |
case 37: values[2]--; e.preventDefault(); break; | |
case 40: values[2]--; e.preventDefault(); break; | |
} | |
} | |
if (e.altKey) { | |
switch (e.which) { | |
case 38: values[3]++; e.preventDefault(); break; | |
case 39: values[3]++; e.preventDefault(); break; | |
case 37: values[3]--; e.preventDefault(); break; | |
case 40: values[3]--; e.preventDefault(); break; | |
} | |
} | |
console.log(values); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment