6.0.0 • Published 7 days ago
react-focus-onkeydown v6.0.0
react-focus-onkeydown
React hook for getting focus of a component when a key is pressed anywhere in the page
Live demo
You can see the simplest demo here: Live demo
Install
$ npm install --save react-focus-onkeydown
Examples
Run examples:
cd examples
npm install
npm start
Usage
import { useRef } from 'react';
import useFocusOnKeyDown from 'react-focus-onkeydown';
const () => {
const ref = useRef(null);
useFocusOnKeyDown(ref);
// Typing any key will trigger a focus on the input below
return <input ref={ref} />;
}
Parameters
ref
Type: ref
, required
ref
to the target element
active
Type: boolean
, default: true
Controls whether or not hook is active (i.e., whether or not a keydown will cause the element to focus)
License
See the LICENSE file for license rights and limitations (MIT).
6.0.0
7 days ago
5.0.2
1 year ago
5.0.1
2 years ago
5.0.0
2 years ago
4.1.0
3 years ago
4.0.0
3 years ago
3.0.1
5 years ago
3.0.0
5 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.0
6 years ago
1.4.0
6 years ago
1.3.1
7 years ago
1.3.0
7 years ago
1.2.0
7 years ago
1.1.1
8 years ago
1.1.0
8 years ago
1.0.0
8 years ago
0.1.1
8 years ago
0.1.0
8 years ago
0.0.1
8 years ago