Keyboard shortcut to invoke a button

I use the code given below to create a button to open a modal window for searching.

<$button>
<$action-sendmessage $message="tm-modal" $param="Context edit"/>
{{$:/images/templarian-material-design/magnify-scan}}
</$button>

Is it possible to create a keyboard shortcut to activate this button?

You need to start following these instructions How to create keyboard shortcuts taking not of Using global Keyboard Shortcuts.

  • Particularly note SystemTag: $:/tags/KeyboardShortcut
  • This means you need to externalise the actions in the above button and you may not need the button to be present when the shortcut is used.
  • Although you could present the button and simultaneously have the keyboard shortcut active and it would look like what you seem to be asking for.

Setting up keyboard shortcuts has never being easy for me, one day, when I come to understand them, I may contribute something to the documentation.

  • The key reason is it is necessary to set things multiple places/tiddlers and details to get them working.
1 Like

Hi, You can activate actions with the $keyboard widget.

Your button code should look like this, to be able to do both.

\define myActions()
<$action-sendmessage $message="tm-modal" $param="Context edit"/>
\end

<$button actions=<<myActions>>>
{{$:/images/templarian-material-design/magnify-scan}}
</$button>

Also see: https://tiddlywiki.com/#KeyboardShortcuts:KeyboardShortcuts%20KeyboardWidget

With the keyboard widget it’s important to have an element that has “focus”. eg: a text input element.

1 Like

This did the trick for me. Thank you all.