d

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567
ouroffice@aware.com

 

KMF

Shortcut Guide Popup Componet For React

A React component that displays a shortcut guide popup on the screen when users press or ?.

How to use it:

1. Install and import the Shortcut Guide component.

# NPM
$ npm i react-shortcut-guide
import React from 'react'
import { render } from 'react-dom'
import { ShortcutProvider } from 'react-shortcut-guide'
render(<App />, document.getElementById('app'))
function App() {
  return (
    <ShortcutProvider
      options={{
        darkMode: 'media',
      }}
    >
      <Comp />
    </ShortcutProvider>
  )
}

2. Register your own keyboard shortcuts.

import { useShortcut } from 'react-shortcut-guide'
useShortcut(
  'A',
  [Modifier.Meta],
  (e) => {
    console.log('a')
  },
  'Print A',
  options,
)

3. Provider options.

type ShortcutOptions = {
  darkMode?: 'media' | 'class'
  /**
   * @default 'body.dark'
   */
  darkClassName?: string
  /**
   * time to wait before triggering the shortcut guide
   * @default 1000
   */
  holdCommandTimeout?: number
  /**
   * time to wait before closing the shortcut guide
   * @default 1000
   */
  stayCommandTimeout?: number
  /**
   * open event
   */
  onGuidePanelOpen?: () => any
  /**
   * close event
   */
  onGuidePanelClose?: () => any
}

4. Hook options.

type RegisterShortcutOptions = {
  /**
   * disable shortcuts on input
   * @default true
   */
  preventInput?: boolean
  /**
   * hide this shortcut?
   * @default false
   */
  hiddenInPanel?: boolean
}

Preview:

Download Details:

Author: reactify-component

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/reactify-component/react-shortcut-guide

License: MIT

Credit: Source link

Previous Next
Close
Test Caption
Test Description goes like this