本页还没有译文
本页 12 段还没译成Français,下面显示的是英文原文。getIsKeyHeld
还没翻译译自英文(tanstack.com)本页 12 段都还没译
function getIsKeyHeld(key): SvelteHeldKeyState;Defined in: packages/svelte-hotkeys/src/getIsKeyHeld.svelte.ts:66
Svelte function that returns reactive access to whether a specific key is currently being held.
This function uses the global KeyStateTracker and updates whenever keys are pressed or released.
Parameters
key
IndividualKey
The key to check (e.g., 'Shift', 'Control', 'A')
Returns
Object with a reactive held property
Examples
<script>
import { getIsKeyHeld } from '@tanstack/svelte-hotkeys'
const isShiftHeld = getIsKeyHeld('Shift')
</script>
<div>
{isShiftHeld.held ? 'Shift is pressed!' : 'Press Shift'}
</div>
<script>
import { getIsKeyHeld } from '@tanstack/svelte-hotkeys'
const isCtrlHeld = getIsKeyHeld('Control')
const isShiftHeld = getIsKeyHeld('Shift')
const isAltHeld = getIsKeyHeld('Alt')
</script>
<div>
<span style:opacity={isCtrlHeld.held ? 1 : 0.3}>Ctrl</span>
<span style:opacity={isShiftHeld.held ? 1 : 0.3}>Shift</span>
<span style:opacity={isAltHeld.held ? 1 : 0.3}>Alt</span>
</div>
AI 翻译查看英文原文