From a765b5ee064380b0ce7908364e573785cc8e3dbc Mon Sep 17 00:00:00 2001 From: Nils Asmussen Date: Sun, 28 Aug 2016 16:15:15 +0200 Subject: [PATCH] Support metaKey and ctrlKey for selection. MetaKey is the windows key on Windows/Linux. Using only that for selecting items is really confusing, because AFAIK no existing application does that. With this commit, ctrl can be used for selecting items as well. --- src/scripts/multiselect.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/scripts/multiselect.js b/src/scripts/multiselect.js index 7760edd..615cdf4 100644 --- a/src/scripts/multiselect.js +++ b/src/scripts/multiselect.js @@ -3,6 +3,12 @@ * @copyright 2015 by Tobias Reich */ +const isSelectKeyPressed = function(e) { + + return e.metaKey || e.ctrlKey + +} + multiselect = { ids: [] @@ -71,8 +77,8 @@ multiselect.albumClick = function(e, albumObj) { let id = albumObj.attr('data-id') - if (e.metaKey===true) multiselect.toggleItem(albumObj, id) - else lychee.goto(id) + if (isSelectKeyPressed(e)) multiselect.toggleItem(albumObj, id) + else lychee.goto(id) } @@ -80,8 +86,8 @@ multiselect.photoClick = function(e, photoObj) { let id = photoObj.attr('data-id') - if (e.metaKey===true) multiselect.toggleItem(photoObj, id) - else lychee.goto(album.getID() + '/' + id) + if (isSelectKeyPressed(e)) multiselect.toggleItem(photoObj, id) + else lychee.goto(album.getID() + '/' + id) } @@ -251,7 +257,7 @@ multiselect.getSelection = function(e) { if (visible.contextMenu()) return false if (!visible.multiselect()) return false - if (e.metaKey===false && (size.width==0 || size.height==0)) { + if (!isSelectKeyPressed(e) && (size.width==0 || size.height==0)) { multiselect.close() return false }