How to use the actionsack.useKeyboardListener function in actionsack

To help you get started, we’ve selected a few actionsack examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github carbon-app / carbon / components / Settings.js View on Github external
function KeyboardShortcut({ trigger, handle }) {
  useKeyboardListener(trigger, handle)
  return null
}
github carbon-app / carbon / components / SelectionEditor.js View on Github external
function SelectionEditor({ onChange }) {
  const [visible, setVisible] = React.useState(false)
  const [open, setOpen] = React.useState(true)

  useKeyboardListener('Escape', () => setVisible(false))

  const [state, dispatch] = React.useReducer(reducer, {
    bold: false,
    italics: false,
    underline: false,
    color: null
  })

  React.useEffect(() => {
    onChange(state)
  }, [onChange, state])

  return (
    <div style="{{">
      </div>
github carbon-app / carbon / components / ExportMenu.js View on Github external
function ExportMenu({
  backgroundImage,
  onChange,
  exportSize,
  isVisible,
  toggleVisibility,
  exportImage: exp
}) {
  const tooLarge = React.useMemo(() =&gt; !verifyPayloadSize(backgroundImage), [backgroundImage])
  const online = useOnline()
  const isSafari = useSafari()

  const [exportImage, { loading }] = useAsyncCallback(exp)
  useKeyboardListener('⌘-⇧-e', () =&gt; exportImage())

  const disablePNG = isSafari &amp;&amp; (tooLarge || !online)

  const input = React.useRef()

  const handleExportSizeChange = selectedSize =&gt; () =&gt; onChange('exportSize', selectedSize)

  const handleExport = format =&gt; () =&gt;
    exportImage(format, {
      filename: input.current.value
    })

  return (
    <div id="export-menu">
      <div>
        </div></div>

actionsack

React UX components for handling common interactions

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis