@tonytino/kekos

1.1.3 • Public • Published

Kekos

Utility package used to easily apply key code support for key press events you'd like to potentially fire a callback in response to.

Getting Started

npm i @tonytino/kekos

Example Usage

import React from "react";
import kekos from "@tonytino/kekos";
import "./App.css";

function App() {
  // Configure your kekos handler
  const onDeleteKeyDown = kekos({
    // Keys permitted to invoke the callback
    keys: ["Backspace"],
    // Callback to invoke
    callback: () => alert("Deleting the card. 🚮"),
  });

  // Pass kekos handler to React Keyboard Event API (e.g. onKeyDown)
  // https://reactjs.org/docs/events.html#keyboard-events
  return <div className="card" onKeyDown={onDeleteKeyDown} tabIndex="0" />;
}

export default App;

Readme

Keywords

Package Sidebar

Install

npm i @tonytino/kekos

Weekly Downloads

1

Version

1.1.3

License

ISC

Unpacked Size

3.46 kB

Total Files

6

Last publish

Collaborators

  • tonytino