Write keys as a +-separated string, ignoring case and spaces. mod means Command on macOS and Ctrl elsewhere; meta is the literal system key. Write the plus key as plus. Unknown tokens display unchanged.
You write
macOS
Windows and Linux
mod
⌘Keyboard shortcut: Command
CtrlKeyboard shortcut: Ctrl
metacmdcommandwinsuper
⌘Keyboard shortcut: Command
WinKeyboard shortcut: Win
ctrlcontrol
⌃Keyboard shortcut: Ctrl
CtrlKeyboard shortcut: Ctrl
altoptionopt
⌥Keyboard shortcut: Alt
AltKeyboard shortcut: Alt
shift
⇧Keyboard shortcut: Shift
ShiftKeyboard shortcut: Shift
enterreturn
↵Keyboard shortcut: Enter
EnterKeyboard shortcut: Enter
escescape
EscKeyboard shortcut: Esc
EscKeyboard shortcut: Esc
space
SpaceKeyboard shortcut: Space
SpaceKeyboard shortcut: Space
backspace
⌫Keyboard shortcut: Backspace
BackspaceKeyboard shortcut: Backspace
deletedel
⌦Keyboard shortcut: Del
DelKeyboard shortcut: Del
tab
⇥Keyboard shortcut: Tab
TabKeyboard shortcut: Tab
updownleftright
↑Keyboard shortcut: Up arrow↓Keyboard shortcut: Down arrow←Keyboard shortcut: Left arrow→Keyboard shortcut: Right arrow
↑Keyboard shortcut: Up arrow↓Keyboard shortcut: Down arrow←Keyboard shortcut: Left arrow→Keyboard shortcut: Right arrow
Place shortcuts beside controls, in menus or in tooltips.
vue
Press Ctrl+KKeyboard shortcut: Ctrl + K to open the command palette, then type the first letters of what you are after. EscKeyboard shortcut: Esc puts it away again.
listen emits trigger for an exact modifier match. allowDefault preserves the browser action; allowInInput enables matching in editable fields. Escape is never cancelled. Matching uses the produced character: prefer letters and named keys over symbols, AZERTY digits or macOS Option-letter combinations.
vue
Ctrl+KKeyboard shortcut: Ctrl + KPress it anywhere on the page. Fired 0 times.
Ctrl+SKeyboard shortcut: Ctrl + S With allowDefault, the browser still saves the page. Fired 0 times.
Ctrl+JKeyboard shortcut: Ctrl + JQuiet while a field has the focus: 0
Ctrl+JKeyboard shortcut: Ctrl + JWith allowInInput, it fires there too: 0
<script setup lang="ts">
import { ref } from 'vue'
import { VHotkeys, VInput, VTypography } from 'vectis-ui'
const opened = ref(0)
const saved = ref(0)
const strict = ref(0)
const permissive = ref(0)
</script>
<template>
<div class="stack">
<p class="line">
<VHotkeys keys="mod+k" variant="outline" listen @trigger="opened++" />
<VTypography as="span">Press it anywhere on the page. Fired {{ opened }} times.</VTypography>
</p>
<!-- allowDefault also lets the browser open its save dialog. -->
<p class="line">
<VHotkeys keys="mod+s" variant="outline" listen allow-default @trigger="saved++" />
<VTypography as="span" tone="muted">
With allowDefault, the browser still saves the page. Fired {{ saved }} times.
</VTypography>
</p>
<VInput label="Type in here, then press the shortcut below" class="field" />
<p class="line">
<VHotkeys keys="mod+j" variant="outline" listen @trigger="strict++" />
<VTypography as="span">Quiet while a field has the focus: {{ strict }}</VTypography>
</p>
<p class="line">
<VHotkeys keys="mod+j" variant="outline" listen allow-in-input @trigger="permissive++" />
<VTypography as="span">With allowInInput, it fires there too: {{ permissive }}</VTypography>
</p>
</div>
</template>
<style scoped>
.stack {
display: flex;
flex-direction: column;
align-items: start;
gap: var(--vectis-space-4);
}
.line {
display: flex;
align-items: center;
gap: var(--vectis-space-3);
margin: 0;
}
.field {
inline-size: 22rem;
}
</style>
API
Props
Prop
Type
Default
keys
string
none
Shortcut string separated by +. Use mod for Command/Ctrl and plus for the plus key.