Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 780 Bytes

README.md

File metadata and controls

33 lines (25 loc) · 780 Bytes

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;