From: gc Date: Fri, 6 May 2005 23:45:40 +0000 (+0000) Subject: copy key shortcuts support in album from albumshaper X-Git-Tag: 0.9.0~550 X-Git-Url: http://git.zarb.org/?p=booh;a=commitdiff_plain;h=7df39d6cd9f20ea47adca999d6d6a297396c12c1 copy key shortcuts support in album from albumshaper --- diff --git a/lib/booh/html-merges.rb b/lib/booh/html-merges.rb index 23c724d..a3bf588 100644 --- a/lib/booh/html-merges.rb +++ b/lib/booh/html-merges.rb @@ -153,6 +153,10 @@ function init() { if (preferred_pause != null) { document.getElementById('secs').value = preferred_pause; } + + if (navigator.userAgent.indexOf('Opera') == -1) { + document.onkeydown = keyDownEvent; + } } function update_sensibilities() { @@ -258,6 +262,37 @@ function last() { display_current(); } +function keyDownEvent(key) { + if (!key) { + key = event; + key.which = key.keyCode; + } + switch (key.which) { + case 36: // home + first(); + break; + case 35: // end + last(); + break; + case 37: // left + previous(); + break; + case 39: // right + next(); + break; + case 38: // up + for (i = 0; i < 10; i++) { + previous(); + } + break; + case 40: // down + for (i = 0; i < 10; i++) { + next(); + } + break; + } +} + function toggle_slideshow(now) { if (slideshow == 0) { slideshow_pause = document.getElementById('secs').value;