@joknoll/svelte-attach
Svelte attachments to add keyboard shortcuts, sound effects, vibration, and gamepad controls to Svelte 5 components.
npm install @joknoll/svelte-attach <script>
import { hotkey } from "@joknoll/svelte-attach/key";
import { sound } from "@joknoll/svelte-attach/sound";
import click from "./click.opus";
</script>
<button {@attach hotkey("mod+s")} {@attach sound(click)}>Save</button>Keyboard
Shortcuts, held states, and shortcut hints.
Hold ShiftSound
Event-driven and manual playback.
Vibration
Vibration presets and custom patterns.
Gamepad
Button activation and state.
Press A