All Projects → jaywcjlove → React Hotkeys

jaywcjlove / React Hotkeys

React component to listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to React Hotkeys

react-hotkey-tooltip
A global Hotkey provider with built in tooltip for React
Stars: ✭ 34 (-87.81%)
Mutual labels:  react-component, hotkeys, shortcut
hotkey
⌨️ cross-platform hotkey package
Stars: ✭ 82 (-70.61%)
Mutual labels:  keyboard, hotkeys, shortcut
g910-gkey-macro-support
GKey support for Logitech G910 Keyboard on Linux
Stars: ✭ 85 (-69.53%)
Mutual labels:  keyboard, hotkeys, shortcut
Hotkeys
➷ A robust Javascript library for capturing keyboard input. It has no dependencies.
Stars: ✭ 5,165 (+1751.25%)
Mutual labels:  shortcut, hotkeys, keyboard
Slowquitapps
Add a global delay to Command-Q to stop accidental app quits.
Stars: ✭ 916 (+228.32%)
Mutual labels:  shortcut, keyboard
Capslock Plus
An efficiency tool that provides various functions by enhancing the Caps Lock key into a modifier key.
Stars: ✭ 650 (+132.97%)
Mutual labels:  shortcut, keyboard
Autohotkey
⚙️ My Autohotkey productivity suite that includes shortcuts, hotstrings, hotkeys, apps/utilities, AutoCorrect
Stars: ✭ 113 (-59.5%)
Mutual labels:  shortcut, hotkeys
keybind
ClojureScript key bindings (shortcut) library
Stars: ✭ 85 (-69.53%)
Mutual labels:  hotkeys, shortcut
Pretzel
Pretzel is Mac desktop app that shows and find keyboard shortcuts based on your current app.
Stars: ✭ 405 (+45.16%)
Mutual labels:  shortcut, keyboard
Ng Keyboard Shortcuts
Dead Simple Keyboard Shortcuts Management for Angular
Stars: ✭ 121 (-56.63%)
Mutual labels:  shortcut, keyboard
metaKeyboard
turn a common keyboard into a 61-key keyboard for the keyboard shortcut fun like you, I'm a programer, I want to improve coding efficiency
Stars: ✭ 30 (-89.25%)
Mutual labels:  keyboard, shortcut
Chordly
Chordly is a javascript library that may be used to detect and act upon key sequences entered by a user.
Stars: ✭ 14 (-94.98%)
Mutual labels:  keyboard, hotkeys
react-keyboard-shortcuts
A declarative library for handling hotkeys based on explicit priority in React applications
Stars: ✭ 23 (-91.76%)
Mutual labels:  keyboard, hotkeys
Hotkey
Simple global shortcuts in macOS
Stars: ✭ 574 (+105.73%)
Mutual labels:  shortcut, keyboard
Globalhooks
Allows you to create global keyboard events
Stars: ✭ 74 (-73.48%)
Mutual labels:  shortcut, keyboard
Selectnextoccurrence
A Visual Studio Extension that selects the next occurrences of the current selection and adds multiple cursors for editing
Stars: ✭ 129 (-53.76%)
Mutual labels:  shortcut, keyboard
Is Hotkey
Check whether a browser event matches a hotkey.
Stars: ✭ 211 (-24.37%)
Mutual labels:  hotkeys, keyboard
Keymage
Yet Another JS Keybinding library
Stars: ✭ 325 (+16.49%)
Mutual labels:  shortcut, hotkeys
react-shortcut
Convenient React component that detects if the given key combination is pressed, and triggers a callback
Stars: ✭ 16 (-94.27%)
Mutual labels:  hotkeys, shortcut
hotscript
HotScript - Revolutionizing how Windows works.
Stars: ✭ 29 (-89.61%)
Mutual labels:  keyboard, shortcut

react-hotkeys

Build & Deploy npm package Coveralls

React component to listen to keydown and keyup keyboard events, defining and dispatching keyboard shortcuts. Uses a fork of hotkeys.js for keydown detection of special characters. You give it a keymap of shortcuts & it bind it to the mousetrap singleton. The, it'll unbind it when the component unmounts.

react-hotkeys-hook - React hook for using keyboard shortcuts in components. Make sure that you have at least version 16.8 of react and react-dom installed, or otherwise hooks won't work for you.

Example

Install

sudo npm i -S react-hot-keys

Demo

Preview demo.

import React from 'react';
import Hotkeys from 'react-hot-keys';

export default class HotkeysDemo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      output: 'Hello, I am a component that listens to keydown and keyup of a',
    }
  }
  onKeyUp(keyName, e, handle) {
    console.log("test:onKeyUp", e, handle)
    this.setState({
      output: `onKeyUp ${keyName}`,
    });
  }
  onKeyDown(keyName, e, handle) {
    console.log("test:onKeyDown", keyName, e, handle)
    this.setState({
      output: `onKeyDown ${keyName}`,
    });
  }
  render() {
    return (
      <Hotkeys 
        keyName="shift+a,alt+s" 
        onKeyDown={this.onKeyDown.bind(this)}
        onKeyUp={this.onKeyUp.bind(this)}
      >
        <div style={{ padding: "50px" }}>
          {this.state.output}
        </div>
      </Hotkeys>
    )
  }
}

API

keyName

Supported keys , shift, option, , alt, ctrl, control, command, .

Command()
Control
Option(alt)
Shift
Caps Lock
fn Function key is fn (not supported)
↩︎ return/enter space space keys

onKeyDown

Callback function to be called when user pressed the target buttons space space keys

onKeyUp

Callback function to be called when user key uped the target buttons

allowRepeat

allowRepeat?: boolean;

allowRepeat to allow auto repeating key down

disabled

disabled?: boolean;

Disable onKeyDown and onKeyUp events. Default: undefined

filter

INPUT SELECT TEXTAREA default does not handle. filter to return to the true shortcut keys set to play a role, flase shortcut keys set up failure.

<Hotkeys 
  keyName="shift+a,alt+s" 
+  filter={(event) => {
+    return true;
+  }}
  onKeyDown={this.onKeyDown.bind(this)}
  onKeyUp={this.onKeyUp.bind(this)}
/>

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].