vue-keycon
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

vue-keycon npm version

Vue 3 Keyboard Controller

Installation

npm i vue-keycon

How to use

<template>
  <div>{{ isKeydown ? "keydown" : "keyup" }}</div>
</template>
<script>
import { useKeycon } from "vue-keycon";

export default {
  setup() {
    const {
      isKeydown,
      onBlur,
      onKeydown,
      onKeyup,
    } = useKeycon({
      // If you want to specify a specific input, use ref. If not used, the event is used for the window.
      ref: containerRef,
      keys: ["shift"],
    });

    onKeydown(() => {
      console.log("keydown");
    });

    onKeyup(() => {
      console.log("keyup");
    });

    onBlur(() => {
      console.log("blur");
    });

    return {
      isKeydown,
    };
  }
}

/vue-keycon/

    Package Sidebar

    Install

    npm i vue-keycon

    Weekly Downloads

    9

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    16.6 kB

    Total Files

    22

    Last publish

    Collaborators

    • younkue