From 35e6c938dc037f0d4e774ebf3307bda7c5c96312 Mon Sep 17 00:00:00 2001 From: Nadav Tasher Date: Sat, 6 Jul 2024 21:26:55 +0300 Subject: [PATCH] Added 'n' shortcut for adding new minicards --- client/lib/keyboard.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 79f90456c..90e3d3f46 100644 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -179,6 +179,30 @@ Mousetrap.bind('c', evt => { } }); +Mousetrap.bind('n', evt => { + const cardId = getSelectedCardId(); + if (!cardId) { + return; + } + + const currentUserId = Meteor.userId(); + if (currentUserId === null) { + return; + } + + if (Utils.canModifyBoard()) { + // Find the current hovered card + const card = ReactiveCache.getCard(cardId); + + // Find the button and click it + $(`#js-list-${card.listId} .list-body .minicards .open-minicard-composer`).click() + + // We should prevent scrolling in card when spacebar is clicked + // This should do it according to Mousetrap docs, but it doesn't + evt.preventDefault(); + } +}); + Template.keyboardShortcuts.helpers({ mapping: [ { @@ -193,6 +217,10 @@ Template.keyboardShortcuts.helpers({ keys: ['a'], action: 'shortcut-filter-my-assigned-cards', }, + { + keys: ['n'], + action: 'add-card-to-bottom-of-list', + }, { keys: ['f'], action: 'shortcut-toggle-filterbar',