Écrivez keys sous forme de chaîne séparée par +, sans distinction de casse ni d’espaces. mod désigne Command sur macOS et Ctrl ailleurs ; meta est la touche système littérale. Écrivez la touche plus avec plus. Les valeurs inconnues s’affichent telles quelles.
Placez les raccourcis à côté des contrôles, dans les menus ou dans les infobulles.
vue
Press Ctrl+KRaccourci clavier : Ctrl + K to open the command palette, then type the first letters of what you are after. ÉchapRaccourci clavier : Échap puts it away again.
listen émet trigger si les touches modificatrices correspondent exactement. allowDefault conserve l’action du navigateur ; allowInInput autorise la détection dans les champs éditables. Échap n’est jamais annulé. La détection utilise le caractère produit : préférez les lettres et touches nommées aux symboles, chiffres AZERTY ou combinaisons Option-lettre sur macOS.
vue
Ctrl+KRaccourci clavier : Ctrl + KPress it anywhere on the page. Fired 0 times.
Ctrl+SRaccourci clavier : Ctrl + S With allowDefault, the browser still saves the page. Fired 0 times.
Ctrl+JRaccourci clavier : Ctrl + JQuiet while a field has the focus: 0
Ctrl+JRaccourci clavier : 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
Défaut
keys
string
aucune
Chaîne de raccourci séparée par +. Utilisez mod pour Command/Ctrl et plus pour la touche plus.
variant
HotkeysVariant'soft' | 'outline' | 'elevated'
'soft'
Style des touches : atténué, avec bordure ou en relief.
attached
boolean
false
Encadre toute la combinaison comme une seule touche.