git.shiar.nl
/
sheet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
keys: javascript mode match reorder, comments
[sheet.git]
/
keys.js
diff --git
a/keys.js
b/keys.js
index b625db79b17a08e533f517a01ad8b2c0e310711b..993e8f458cc76ae300971d4c9532a2beb2f6d7af 100644
(file)
--- a/
keys.js
+++ b/
keys.js
@@
-23,19
+23,27
@@
document.onkeypress = function(e) {
keys[keylabels[i].innerHTML] = keylabels[i].parentNode;
}
var input = e.charCode || e.keyCode;
keys[keylabels[i].innerHTML] = keylabels[i].parentNode;
}
var input = e.charCode || e.keyCode;
+
+ // find key element matching input
for (var i = 0; i < keylabels.length; i++) {
var key = keylabels[i].parentNode;
for (var i = 0; i < keylabels.length; i++) {
var key = keylabels[i].parentNode;
- if (!key.onclick) continue;
+ if (!key.onclick) continue;
// link
var keychar = key.className.match(/ chr(\d+)$/);
var keychar = key.className.match(/ chr(\d+)$/);
- if (!keychar) continue; //
not enterabl
e
+ if (!keychar) continue; //
has cod
e
keychar = keychar[1];
keychar = keychar[1];
- if (keychar != input) continue; // different key
+ if (keychar != input) continue; // matches code
+
+ // match mode (visibility)
var row = key.parentNode;
var row = key.parentNode;
+ var shown = row.style.display != 'none';
+ if (!shown) continue;
+
+ // match key modifiers
var keymod = row.className;
var keymod = row.className;
- if ((keymod.search(/\bctrl\b/) != -1) != e.ctrlKey) continue;
// modifier mismatch
+ if ((keymod.search(/\bctrl\b/) != -1) != e.ctrlKey) continue;
if ((keymod.search(/\bmeta\b/) != -1) != e.altKey) continue;
if ((keymod.search(/\bmeta\b/) != -1) != e.altKey) continue;
- var shown = row.style.display != 'none';
- if (!shown) continue; // foreign mode
+
+ // select
if (keyfocus) keyfocus.style.outline = '';
key.style.outline = '1px solid red';
keyfocus = key;
if (keyfocus) keyfocus.style.outline = '';
key.style.outline = '1px solid red';
keyfocus = key;