You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

toukey

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toukey

Toukey is a Javascript library for keyboard shortcuts

1.3.1
latest
Version published
Weekly downloads
56
-38.46%
Maintainers
1
Weekly downloads
 
Created

Toukey

npm GitHub npm bundle size

Toukey is a simple and efficient keyboard events library. That's toukey's doc site.

Install

npm i toukey --save

or

pnpm add toukey --save

Use

Browser

You could download and link toukey.js in your HTML, It can also be downloaded via UNPKG | jsDelivr

<script src="https://unpkg.com/toukey/dist/toukey.umd.min.js"></script>
<script>
  toukey.subscribe('space', function() {
    console.log('space');
  });
</script>

React

It is easy to use with react.

import { useEffect } from "react";
import { subscribe } from "toukey";

function App() {
  useEffect(() => {
    return subscribe("scope", () => {
      console.log("scope");
    });
  });

  return <div>hello world</div>;
}

And here is a library named react-toukey-hook which build with toukey for react hook.

Basic Use

import * as Toukey from "toukey";

const handler = () => console.log("handler");

// subscribe
Toukey.on("scope", handler);

// unsubscribe
Toukey.off("scope", handler);
import { subscribe } from "toukey";

const unsubsribe = subscribe("scope", () => {
  console.log("scope");
});

FAQs

Package last updated on 19 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts