Can I disable some specific shortcut (e.g. Ctrl + A
) in some way?
I tried to use preventDefault
, stopPropagation
and stopImmediatePropagation
in beforeKeyDown
hook when this shortcut keys pressed but it doesn’t prevent action.
Specific shortcut disabling
Yes, there’s a pretty new API called ShortcutManager. Here’s a demo https://jsfiddle.net/fzeuy3px/4/ (v13.1.)
Here yu can read more about the changes done in v12 https://handsontable.com/docs/javascript-data-grid/release-notes/#_12-0-0 where ShortcutManager was introduced.
You’re more than welcome wish you great weekend
Btw, @aleksandra_budnik
Where I can find key name of shortcut? I mean, for shortcut Ctrl + A
you wrote ['control/meta', 'a']
. How to correctly describe this one Ctrl + ←
or Ctrl + Shift + Space
etc?
Here https://handsontable.com/docs/javascript-data-grid/keyboard-shortcuts/#keyboard-shortcut-contexts is the full list of shortcuts that we use.
And here https://handsontable.com/docs/javascript-data-grid/custom-shortcuts/ you can check how contexts work (grid
is the one that is used for navigation)
But you’re right I do not see any place where we say that Command (macOS) is called meta
key. I will make a note to change that.
Hi @aleksandra_budnik
I seen with list (first link) before, but there is no names of shortcut keys. For example, there wrote Ctrl + ←
, but no information about name of ←
. It may be arrow_right
or right_arrow
or ArrowRight
etc.
That is 100% true. I left a note to the Technical Writer to update the documentation.
The keys (strings) that need to be provided, are defined at https://github.com/handsontable/handsontable/blob/31297ac68fbe7020a6554da2f567ece42d3e1b3e/handsontable/src/shortcuts/context.js#L79C17-L79C34 and those are what the native event.key
returns.
So what I recommend is
- have this list opened https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values
- test it here https://jsfiddle.net/0L9gemr1/
ps. Capitalization doesn’t matter ‘A’ is the same as ‘a’.*
You’re welcome @denial.trombol
If you’d need anything else, please feel free to open a new thread or contact me at support@handsontable.com