Shortcut
Renders key glyphs such as ⌘K. While it is mounted, pressing those keys clicks the
button or link it sits in, or calls ontrigger.
K
Installation
Copy the command below and run it in your terminal.
Usage
Join keys with +, as in ctrl+shift+P. cmd matches the Meta key only; use ctrl for Control. A Shortcut outside a button or link without ontrigger only displays. Keys typed into a field are ignored, except Enter and Escape in an input.
A Shortcut inside an overlay that another overlay covers does not fire. The chip is
hidden below the sm breakpoint, but the binding stays active.
Examples
Basic
K
With modifiers
⌘K ⇧/
In context
Anatomy
Shortcut - Displays a keyboard shortcut and clicks its owner when pressed.
<script lang="ts"> import { Button } from '@sivir-ui/svelte/components/button'; import Shortcut from '@sivir-ui/svelte/components/shortcut'; import { toast } from '@sivir-ui/svelte/components/toast'; function ontrigger() { toast({ title: 'Shortcut activated', description: 'Pressed K', duration: 2000, type: 'success' }); } </script> <div class="flex flex-wrap items-center justify-center gap-3"> <Button variant="ghost"> Cancel <Shortcut shortcut="esc" /> </Button> <Button> Save <Shortcut shortcut="enter" /> </Button> <Shortcut shortcut="K" {ontrigger} /> </div>