import * as React from "react"; import Code from "../Code"; export default function Shortcuts() { return (
kbar comes out of the box for registering keystroke patterns and triggering actions even when kbar is hidden.
When registering an action, passing a valid property to{" "}
shortcut will ensure that when users' keystroke pattern
matches, that kbar will trigger that action.
Imagine if you wanted to open a link to Twitter when the user types{" "} g+t, the action would look something like this:
window.open("https://twitter.com/jack", "_blank")
})`}
/>
You can also use shortcuts to open kbar at a specific parent action. For
example, if a user types ?, you want to open kbar with the
nested actions for "Search docs". Try it on this site – press{" "}
? and you will see the results for searching through docs
immediately shown.
Actions without a perform property will already have this
implicitly handled.
Changing the default command+k shortcut
Say you want to trigger kbar using a different shortcut, cmd+
shift+p.
You can override the default behavior by passing a valid string sequence
to KBarProvider.options.toggleShortcut based on{" "}
tinykeys
.