From: Arun Persaud Date: Sat, 17 Nov 2012 23:09:31 +0000 (-0800) Subject: add keyboard shortcuts for prev/next image X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=photo-tags.git;a=commitdiff_plain;h=68246bb37ea3eaba59e3fb6af80d541bfd345f38 add keyboard shortcuts for prev/next image --- diff --git a/js/photo-tags.js b/js/photo-tags.js index 2b21eb5..238575d 100644 --- a/js/photo-tags.js +++ b/js/photo-tags.js @@ -219,9 +219,15 @@ function update_thumbnails(){ if (IDprev != -1 ) d3.select(".left" ).on("click", function() { load_pic(IDprev); }); if (IDnext != -1 ) - d3.select(".right").on("click", function() { load_pic(IDnext); }); - - }); + d3.select(".right").on("click", function() { load_pic(IDnext); }); + + /* keyboard shortcuts */ + $(document) + .keydown( function (e) { + if(e.which == 37 && IDprev != -1) { $(document).unbind('keydown'); load_pic(IDprev); } + if(e.which == 39 && IDnext != -1) { $(document).unbind('keydown'); load_pic(IDnext); } + }); + }); } function checkbutton()