@alobato/use-key-press

React hook to detect key press

Usage no npm install needed!

<script type="module">
  import alobatoUseKeyPress from 'https://cdn.skypack.dev/@alobato/use-key-press';
</script>

README

useKeyPress

React hook to detect key press

Note: This is using the new React Hooks API

You'll need to install react, react-dom, etc at ^16.8.0 or above

Install

yarn add @alobato/use-key-press

Usage

import useKeyPress from '@alobato/use-key-press'
...
const escPress = useKeyPress('Escape') 
if (escPress) handleExit()