Keyboard Shortcut for Menu Bar Search

Is there a way to assign a keyboard shortcut to the search bar in the bar at the top added by the Menu Bar plugin? All I see in Preferences > Keyboard Shortcuts is a way to assign a shortcut to the search in the sidebar, which doesn’t help when the sidebar is collapsed.

For a quick and dirty way you can modify the action for the existing sidebar search in $:/core/ui/KeyboardShortcuts/sidebar-search

Change

<$action-sendmessage $message="tm-focus-selector" $param=".tc-search input"/>

to

<$action-sendmessage $message="tm-focus-selector" $param=".tc-menubar input"/>

That will cause the existing search keyboard shortcut to select the input box in the menubar instead of the one in the sidebar search.

See this link for the related tiddlers:
https://tiddlywiki.com/#%24%3A%2Fcore%2Fui%2FKeyboardShortcuts%2Fsidebar-search:%24%3A%2Fcore%2Fui%2FKeyboardShortcuts%2Fsidebar-search%20[[WidgetMessage%3A%20tm-focus-selector]]%20[[How%20to%20create%20keyboard%20shortcuts]]

2 Likes

This makes lots of sense to me: anyone who has the menubar at top (with search there) is not likely to miss having a keyboard shortcut for the sidebar version of the same search input box. We might even remove the sidebar version of search (and perhaps add the advanced search button to menubar as well, as a visual reminder in case advanced-search keyboard shortcut is not known/recalled).

That gave me exactly what I needed, thanks!

One addendum: it is possible to add a separate shortcut and have both intact. Following How to create keyboard shortcuts, you can add a net new shortcut by creating the following tiddlers.

tags: 
title: $:/config/ShortcutInfo/menubar-search

Select the menubar search field

and

key: ((menubar-search))
tags: $:/tags/KeyboardShortcut
title: $:/core/ui/KeyboardShortcuts/menubar-search

<$action-sendmessage $message="tm-focus-selector" $param=".tc-menubar input"/>

This will make menubar-search appear as a separate shortcut under Control Panel > Keyboard Shortcuts.

1 Like