1.1.3 • Published 5 years ago

@tonytino/kekos v1.1.3

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

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;
1.1.3

5 years ago

1.1.0

5 years ago