1.0.0 • Published 10 months ago

astro-keyboard-controls v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

npm npm Build Status Known Vulnerabilities

Astro Keyboard Controls

An Astro component that allows you to easily bind to specific keyboard keys and focus on a specific element based on a passed selector string.

Installation

npm install astro-keyboard-controls

Example

---
import KeyboardControls from 'astro-keyboard-controls';

---

<Layout {meta}>
	<KeyboardControls selector="div#search input" key="/" />
    <div id="search">
        <input type="text" />
    </div>
</Layout>

Available component props

NameTypeExampleDescription
selectorStringdiv#search inputA string specifying the selector that is passed to document.querySelector()
siteString/The keyboard key to bind with an event listener for keydown

Author

Liran Tal liran@lirantal.com