no warnings 'uninitialized'; # save some useless checks for more legible code
use Carp;
-our $VERSION = '1.02';
+our $VERSION = '1.03';
my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
my @rowdesc = qw(numeric top home bottom);
$onclick .= sprintf(q{ onclick="document.location='%s'"}, $1)
if $flags =~ s/ ?\blink(\S*)//;
my $keyhint = defined($mnem) && qq{ title="$mnem"};
+ $flags .= ' chr'.ord(substr $key, -1) if $key ne '^0';
print qq{\t\t<li class="$flags"$onclick><b$keyhint>$keytxt</b>};
print ' ', $desc if defined $desc;
}
}
+var keyfocus = undefined;
+document.onkeypress = function(e) {
+ var keylabels = document.getElementById('rows').getElementsByTagName('B');
+ var keys = {};
+ for (var i = 0; i < keylabels.length; i++) {
+ keys[keylabels[i].innerHTML] = keylabels[i].parentNode;
+ }
+ var input = e.charCode || e.keyCode;
+ for (var i = 0; i < keylabels.length; i++) {
+ var key = keylabels[i].parentNode;
+ var keychar = key.className.match(/ chr(\d+)$/);
+ if (!keychar) continue; // not enterable
+ keychar = keychar[1];
+ if (keychar != input) continue; // different key
+ var keymod = key.parentNode.className;
+ if ((keymod.search(/\bctrl\b/) != -1) != e.ctrlKey) continue; // modifier mismatch
+ if ((keymod.search(/\bmeta\b/) != -1) != e.altKey) continue;
+ var row = key.parentNode.parentNode;
+ var shown = row.style.display != 'none';
+ if (!shown) continue; // foreign mode
+ if (keyfocus) keyfocus.style.outline = '';
+ key.style.outline = '1px solid red';
+ keyfocus = key;
+ if (key.onclick) key.onclick();
+ return false;
+ }
+}
<li class="row">
<ul class="keys omni">
- <li class="me" onclick="setmode()"><b>Esc</b>
+ <li class="me chr27" onclick="setmode()"><b>Esc</b>
<!-- static reset button, even though it's not (officially) in the game -->
</ul>
</li>
<li class="row">
<ul class="keys omni">
- <li class="mo" onclick="setmode()"><b>Esc</b> normal mode
+ <li class="mo chr27" onclick="setmode()"><b>Esc</b> normal mode
<!-- not as static anymore, but never bothered; just see ^[ -->
</ul>
</li>
<li class="row">
<ul class="keys omni">
- <li class="mv" onclick="setmode()"><b>Esc</b> normal mode
+ <li class="mv chr27" onclick="setmode()"><b>Esc</b> normal mode
<!-- not as static anymore, but never bothered; just see ^[ -->
</ul>
</li>