From 6df9ce23ab9c8a7a9b9dc055a78aa796a701362c Mon Sep 17 00:00:00 2001 From: Bala Clark Date: Wed, 31 Aug 2011 00:15:12 +0200 Subject: [PATCH] keyboard shortcut for image control --- lib/ComicBook.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/ComicBook.js b/lib/ComicBook.js index 6c53eac..4951afb 100755 --- a/lib/ComicBook.js +++ b/lib/ComicBook.js @@ -52,7 +52,10 @@ function ComicBook(id, srcs, opts) { enhance: {}, keyboard: { next: 78, - previous: 80 + previous: 80, + control: { + image: 69 + } } }; @@ -250,6 +253,14 @@ function ComicBook(id, srcs, opts) { ComicBook.prototype.hideControl = function(control) { this.getControl(control).hide(); } + + ComicBook.prototype.toggleControl = function(control) { + if (this.getControl(control).is(":visible")) { + this.hideControl(control); + } else { + this.showControl(control); + } + } /** * Get the image for a given page. @@ -592,8 +603,12 @@ function ComicBook(id, srcs, opts) { side = getCursorPosition(e); break; case "keydown": + if (e.keyCode === options.keyboard.previous) { side = "left"; } if (e.keyCode === options.keyboard.next) { side = "right"; } + if (e.keyCode === options.keyboard.control.image) { + ComicBook.prototype.toggleControl("image"); + } break; default: throw "invalid navigation event: " + e.type;