From dc476cc5961e6326e9a922f9eb8b1220a6d7ae41 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 1 Sep 2008 15:10:33 +0000 Subject: [PATCH] keyboard controls --- include/gallery.js | 14 ++++++++++++++ include/show.js | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/gallery.js b/include/gallery.js index 1bc4ece..a870a03 100644 --- a/include/gallery.js +++ b/include/gallery.js @@ -91,6 +91,20 @@ function init_gallery() { }; var show = new Show(vimgs,showwin,ctl,showparms); + document.addEvent('keypress', function(ev){ + if (ev.key == 'esc') { + show.exit(); + } else if (ev.key == 'left') { + show.prev(); + } else if (ev.key == 'right') { + show.next(); + } else if (ev.key == 'space') { + show.toggleplay(); + } else { + /* alert('keypress: '+ev.key); */ + } + }); + /* Update HTML */ $$('.conceal').each(function(el){ diff --git a/include/show.js b/include/show.js index 5245232..1a40c56 100644 --- a/include/show.js +++ b/include/show.js @@ -96,7 +96,7 @@ var Show = new Class({ if (this.currentid > 0) { this.show(this.currentid-1); } else { - alert('show.prev called beyond first element'); + /* alert('show.prev called beyond first element'); */ } }, @@ -113,11 +113,16 @@ var Show = new Class({ this.controls.running(1); }, + toggleplay: function(){ + if (this.isplaying) { this.stop(); } + else { this.play(); } + }, + next: function(){ if (this.currentid < this.vimgs.length-1) { this.show(this.currentid+1); } else { - alert('show.next called beyond last element'); + /* alert('show.next called beyond last element'); */ } }, -- 2.39.2