-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeypress.js
46 lines (34 loc) · 880 Bytes
/
keypress.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Code taken from: https://github.com/GeorgeGally/rbvj George Gally
*/
function onKeyDown(event) {
//console.log(event.keyCode);
var keyCode = event.keyCode;
// CHANGE FILE // keys a-z
if (keyCode >= 65 && keyCode <= 90) {
changeFile(keyCode - 65);
// CHANGE SET AND BANK // keys 0-9
} else if (keyCode >= 48 && keyCode <= 57) {
if(event.shiftKey) {
changeSet(keyCode-48);
} else {
changeBank(keyCode-48);
}
// ~ SHOW MOUSE
} else if (keyCode == 192) {
showMouse();
}
}
window.addEventListener('keydown', function(e) {
if (typeof onKeyDown == 'function') onKeyDown(e);
});
var cursor = false;
function showMouse(){
console.log("showMouse");
cursor = !cursor;
if(cursor) {
window.document.body.style.cursor = 'auto';
} else {
window.document.body.style.cursor = 'none';
}
}