This is a toast message function for React development notifications
- Supports dom onKeyDown
- Supports not repeat onKeyDown
- componentOnMount add listen, componentUnMount remove listen
yarn add @acrool/react-hotkey
import {generateOnKeydown, HotkeyListener} from '@acrool/react-hotkey';
const Example = () => {
const handleSave = () => {
// white yourr code
}
const handleCancel = () => {
// white yourr code
}
/**
* Save
*/
const handleOnKeyDown = (e) => {
generateOnKeydown('ctrl+enter', handleSave)(e);
generateOnKeydown('escape', handleCancel)(e);
};
return (<>
<input type="text" onKeyDown={handleOnKeyDown}/>
<HotkeyListener hotKey="ctrl+," onKeyDown={() => console.log('to setting')} />
</>
);
};
There is also a example that you can play with it: