react-keyboard-shortcut

This doesn't render anything, but it modifies the title (or data-shortcut, if secret is set) attribute of its child to be picked up by the title-shortcut-handler lib.

Usage no npm install needed!

<script type="module">
  import reactKeyboardShortcut from 'https://cdn.skypack.dev/react-keyboard-shortcut';
</script>

README

This doesn't render anything, but it modifies the title (or data-shortcut, if secret is set) attribute of its child to be picked up by the title-shortcut-handler lib.

import Shortcut from 'react-keyboard-shortcut';

<Shortcut char="+">
  <button type="button" title="Add one">Increment</button>
</Shortcut>

<Shortcut ctrl char="W" secret>
  <button type="button">Close window</button>
</Shortcut>