From cf90511f3c037f40cac4c5a0ebcc1c156c794874 Mon Sep 17 00:00:00 2001 From: Nadav Tasher Date: Sat, 6 Jul 2024 21:50:59 +0300 Subject: [PATCH] Added multi-language support for keyboard shortcuts --- client/lib/keyboard.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 79f90456c..41d1edce7 100644 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -3,6 +3,17 @@ import { ReactiveCache } from '/imports/reactiveCache'; // XXX There is no reason to define these shortcuts globally, they should be // attached to a template (most of them will go in the `board` template). +window.addEventListener('keydown', (e) => { + // Only handle event if coming from body + if (e.target !== document.body) return; + + // Only handle event if it's in another language + if (String.fromCharCode(e.which).toLowerCase() === e.key) return; + + // Trigger the corresponding action + Mousetrap.trigger(String.fromCharCode(e.which).toLowerCase()); +}); + function getHoveredCardId() { const card = $('.js-minicard:hover').get(0); if (!card) return null;