Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vooks

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vooks - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

3

es/use-keyboard.d.ts

@@ -0,1 +1,2 @@

import { Ref } from 'vue';
interface useKeyboardOptions {

@@ -19,3 +20,3 @@ keyup?: UseKeyboardHandlers;

}
export default function useKeyboard(options?: useKeyboardOptions): Readonly<UseKeyboardState>;
export default function useKeyboard(options?: useKeyboardOptions, enabledRef?: Ref<boolean>): Readonly<UseKeyboardState>;
export {};

@@ -1,4 +0,4 @@

import { onBeforeMount, onBeforeUnmount, reactive, readonly } from 'vue';
import { onBeforeMount, onBeforeUnmount, reactive, readonly, watch } from 'vue';
import { on, off } from 'evtd';
export default function useKeyboard(options = {}) {
export default function useKeyboard(options = {}, enabledRef) {
const state = reactive({

@@ -83,10 +83,26 @@ ctrl: false,

onBeforeMount(() => {
on('keydown', document, keydownHandler);
on('keyup', document, keyupHandler);
if (enabledRef === undefined || enabledRef.value) {
on('keydown', document, keydownHandler);
on('keyup', document, keyupHandler);
}
if (enabledRef !== undefined) {
watch(enabledRef, value => {
if (value) {
on('keydown', document, keydownHandler);
on('keyup', document, keyupHandler);
}
else {
off('keydown', document, keydownHandler);
off('keyup', document, keyupHandler);
}
});
}
});
onBeforeUnmount(() => {
off('keydown', document, keydownHandler);
off('keyup', document, keyupHandler);
if (enabledRef === undefined || enabledRef.value) {
off('keydown', document, keydownHandler);
off('keyup', document, keyupHandler);
}
});
return readonly(state);
}

@@ -0,1 +1,2 @@

import { Ref } from 'vue';
interface useKeyboardOptions {

@@ -19,3 +20,3 @@ keyup?: UseKeyboardHandlers;

}
export default function useKeyboard(options?: useKeyboardOptions): Readonly<UseKeyboardState>;
export default function useKeyboard(options?: useKeyboardOptions, enabledRef?: Ref<boolean>): Readonly<UseKeyboardState>;
export {};

@@ -5,3 +5,3 @@ "use strict";

const evtd_1 = require("evtd");
function useKeyboard(options = {}) {
function useKeyboard(options = {}, enabledRef) {
const state = vue_1.reactive({

@@ -86,8 +86,24 @@ ctrl: false,

vue_1.onBeforeMount(() => {
evtd_1.on('keydown', document, keydownHandler);
evtd_1.on('keyup', document, keyupHandler);
if (enabledRef === undefined || enabledRef.value) {
evtd_1.on('keydown', document, keydownHandler);
evtd_1.on('keyup', document, keyupHandler);
}
if (enabledRef !== undefined) {
vue_1.watch(enabledRef, value => {
if (value) {
evtd_1.on('keydown', document, keydownHandler);
evtd_1.on('keyup', document, keyupHandler);
}
else {
evtd_1.off('keydown', document, keydownHandler);
evtd_1.off('keyup', document, keyupHandler);
}
});
}
});
vue_1.onBeforeUnmount(() => {
evtd_1.off('keydown', document, keydownHandler);
evtd_1.off('keyup', document, keyupHandler);
if (enabledRef === undefined || enabledRef.value) {
evtd_1.off('keydown', document, keydownHandler);
evtd_1.off('keyup', document, keyupHandler);
}
});

@@ -94,0 +110,0 @@ return vue_1.readonly(state);

{
"name": "vooks",
"version": "0.0.5",
"version": "0.0.6",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc