Skip to content

Instantly share code, notes, and snippets.

@Franckapik
Created May 4, 2020 21:27
Show Gist options
  • Save Franckapik/8495f7e5abb749fce2b53b99cdf251fe to your computer and use it in GitHub Desktop.
Save Franckapik/8495f7e5abb749fce2b53b99cdf251fe to your computer and use it in GitHub Desktop.
import {useHotkeys} from 'react-hotkeys-hook'
import { useStoreState, useStoreActions, action } from 'easy-peasy';
const KeyControls= (props) => {
const moveUP = useStoreActions(action => action.moveUP)
useHotkeys('up', event => {
if (event.type === "keydown") {
console.log("down");
} else if (event.type === 'keyup') {
console.log("up");
}
moveUP('up')
});
return null
}
export default KeyControls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment