Giter VIP home page Giter VIP logo

vue-shortkey's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-shortkey's Issues

ESC + textarea

Hey,

Thank you for that lovely plugin. It's very useful!

My use case is following:
I open modal when "n" is pressed. Then i focus so that user can type in whatever needed. What i'd like to achieve is: when user presses "ESC" key, modal is closed. Since i use: Vue.use(ShortKey, { prevent: ['input', 'textarea'] }) and i'm in the focused input field, obviously shortcut call is prevented. I'm actually not sure how can i make ESC and only ESC work only in the input field.

Any thoughts on that?

How to implement multiple shortcut key?

Hi Fagner Araujo,

Thank you for your useful plugin.
I have a problem and need your help.

I have a button, I want when I press Ctrl + 1, the program will execute theAction1 () and when I press Ctrl + 2, the program will execute theAction2 ().

<button
v-shortkey="[['ctrl', '1'], ['ctrl', '2']]"
@shortkey="[theAction1(), theAction2()]">Open

Currently I have no way to solve this problem.
Can you give me some suggestions or how to handle that problem?

Thank you again.

Shortkey fires only on last instance of component

If I have the following template:

<template>
    <div class="template-root">
        <my-comp v-shortkey.native="['meta', 'enter']" @shortkey="() => console.log('1')" />
        <my-comp v-shortkey.native="['meta', 'enter']" @shortkey="() => console.log('2')" />
        <my-comp v-shortkey.native="['meta', 'enter']" @shortkey="() => console.log('3')" />
    </div>
</template>

and I then use the key combination, the console will only display '3', ignoring which component has focus or even if none of them has focus.

Not sure if that can be addressed at all really, but I thought I'd log that here to bring it to your attention.

Shortkeys are not working when language is changed

I have key combinations involving Alt and Shift. On Windows, those two keys are used to switch the input language. If I have a shortkey for Alt+A, it works perfectly if I'm writing in English. However, if I accidentally switch to my other language (Bulgarian), the shortkey no longer works. I guess it's because the a key is now ь, and I have no combination set for Alt+ь.

However, I noticed that when I press the a, it has the same keycode (65) no matter what language I'm writing in. Perhaps an option can be implemented that allows you to use keycodes to monitor the keys?

Span over multiple components

Hi!

Is there a way to use the keypress event over multiple elements at the same time?

For example, I have a list of components created using v-for (i.e., the various instances use the same base component) and I would like to perform some action over all of them when pressing shift.

Thank you!

Readme fix

Hello there, you killed my hour :(
Please fix readme file,
escape => esc shortkey

only works on last added element

Seems that only the last element I've added reacts to the shortcut. I added 2 elements first and tested it and only second element reacted to the shortcut, then I added the third element and only that element reacted to the shortcut.

Is this the way it should be or am I doing something strange with my components :)
I am using this inside file component which I then use to create elements with v-for.

I am also using vuex, not sure if that could somehow interfere with shortcut directive?

Here is how i am using it:

<div v-shortkey.once="['ctrl', 'alt', 'o']" @shortkey="showHeader=!showHeader" v-show="showHeader" class="content-block-header">

Basically, I want to hide the header div of every component that I've added to the list and that is being displayed on the page.

backspace key

Hi there!

Thank you very much for this plugin!

I wanted to catch the key event backspace. But at least on a Mac the 'del' shortkey is not triggered when pressing backspace. Did I miss something or is it just not included so far? If so, could you maybe add it?

can it exclude input and text areas ?

it might usually not good approach to set c as a short key but I had to do it for my purpose. so when I use input text/text area and type c , it fires up the short cut key. If there is a way to exclude the input and text areas that would be great

Modify files?

Got some fixes for IE11 I think but I'm getting error while running "npm run-script build" even if it says "finished".

Steps taken:

  1. Download package.
  2. Edit src/index.js
  3. edit package.json/scripts/build to SET NODE_ENV=production & node build/build.js (im using windows).
  4. run "npm run-script build"

Chrome console says " Failed to resolve directive: shortkey".
The dist/index.js file is inside the zip.

index.zip

Multiple shortcuts per element?

Is it possible to have multiple shortcuts per elements somehow?

I need:

  • cmd + c to copy
  • cmd + d to duplicate

Having the attribute multiple times does not work:

 - duplicate attribute: v-shortkey
 - duplicate attribute: @shortkey

Mac option key

What should I do for the "option" key in Mac?
I tried "alt", but it doesn't work

More than two keys doesn't work

I've been testing a few combinations and haven't gotten a keybind with more than 2 keys to work. For example, ctrl + m works but ctrl + shift + m doesn't. Additionally, ctrl + alt works but ctrl + alt + m does (although neither does alt + m...).

<template>
  <div id="app">
    <v-app
      v-shortkey="['ctrl', 'm']"
      @shortkey.native="onToggle()"
    >
      <v-content>
        <router-view/>
      </v-content>
    </v-app>
  </div>
</template>

I am using Chrome on a Mac.

Cmd on mac

It would be nice to allow the option to use "cmd" instead of "ctrl" when someone is using a mac 😊

Problem with Internet Explorer 11

Hi!,

I just added the vue-shortkey library to my project and I noticed some bugs in Internet Explorer 11. When I opened the developer's web console, I found the following messages:

In Spanish:

  • SCRIPT438: El objeto no acepta la propiedad o el mΓ©todo 'find'.
    In English:
  • SCRIPT438: The object does not accept the 'find' property or method.
    Here an image:
    image

Am I doing something wrong or is it a bug?
Regards.

How can I prevent hotkeys from firing while writing text in a span?

Hi

I have the following components:

A "Home" component which looks like this:

<template>
  <div class="home" v-shortkey="['a']" @shortkey="goToAdd()">
    <v-subheader>Active ({{ activeTodos.length }})</v-subheader>
    <TodoList :todos="activeTodos"></TodoList>
    <router-link to="/add">
      <v-btn fab bottom right color="pink" dark fixed>
        <v-icon>add</v-icon>
      </v-btn>
    </router-link>
  </div>
</template>

And down in the tree of the shown TodoList another component, which lets me edit the description of a todo:

<template>
  <div class="disablehotkeys">
    <span v-shortkey.avoid contenteditable class="disablehotkeys description subheading" @blur="updateDescription($event)">{{ todo.description }}</span>
  </div>
</template>

Now, when the span-tag is focused and I am typing a word with an "a", the shortkey event of the Home component is firing, even though I have disabled v-shortkey on the tag (and the div).

I am initialising vue-shortkey with Vue.use(VueShortkey, { prevent: ["input", "textarea", ".disablehotkeys"] });

How can I prevent the event from firing?

Handle groups of clicks (ff for example)

Any idea where in the code I would be looking to change to support group combinations of clicks. For example, debouncing the keyup event for 200ms to support two separate clicks of a key or clicks to two separate keys in quick succession.

Cheers.

multi key

Thank you for updating.
I updated to 3.0.0.
And add the code:
<span v-shortkey="{win:['ctrl', 'd'],mac:['meta', 'd']}" @shortkey="test"></span>
But the console shows:
Error in directive shortkey bind hook: "TypeError: n.join is not a function"
Is there anything I need to do?
Thank you

Preventing Google Chrome default shortcuts

It is possible to prevent or override web browser sortcuts (ie Google Chrome) ?
I'm trying to use v-shortkey="['ctrl', 'tab']" | | v-shortkey="['ctrl', 's']" but chrome shortcut fires.

Thank you.

Problem with 'Avoided fields'

Hi there. According to the description, I can disable the shortkey by 3 ways. However, when I try to disable it at one specific component in my project which is not an input field, all methods failed. I tried to put 'v-shortkey.avoid' at the root element in that component, and put it's root element class name in the 'prevent' array. The shortkey still works. Could any one help me out? Thank you

Binding to any key-character

How can I bind an action to the @ character? I do not want to assume this is the ['shift', '2'] combination, and even this does not seem to work.

Shortcuts fire even though they are listed in the "prevent" array when initialized

I have an <input type="text" class="form-input" v-shortkey="{up: ['arrowup'], down: ['arrowdown'], tab: ['tab'], esc: ['esc'], enter: ['enter']}" @shortkey="handleShortcut"> input box in my project. It works fine however, it invokes these keyboard shortcuts throughout the app. I understand that this is the standard behavior of vue-shortkey however, it is breaking some functionality of vue-tags-input.

vue-tags-input creates an input box like this: <input type="text" class="new-tag-input valid"> which allows the user to enter tags and use arrow keys to select suggestions. To avoid the conflict, I am initializing vue-shortkey like this:

Vue.use(VueShortkey, { prevent: ['input.valid'] });

While this fixed my issue with vue-tags-input (I am able to use my arrow keys to select tags), it broke my other input above (the one with class="form-input" which actually has the v-shortkey attribute). vue-shortkey has disabled all shortcuts on input.form-input. I am using vue-shortkey version 3.1.0. How can I fix this?

Do not work with russian keyboard layout

Shortkeys do not work if i change keyboard layout from english to russian or other layouts.
If i define ['ctrl', 'a'] shortkey and then change language then shortkey is not working, but if define it in the target language then in works. For example:

['ctrl', 'a'] -- is not working in russian or other non ASCII language
['ctrl', 'Ρ„'] -- works in russian
( 'a' and 'Ρ„' share same key on keyboard)

Ofcourse this is not a bug, but just a little inconvenience. Is there a way to define shortkeys that would work if the letters share same keyboard key
independently from selected language?

UPD:
Solution: https://www.npmjs.com/package/vue-shortkey#multi-keys. So i can define key combinatioins for all target languages

v-shortkey.avoid documentation

The documentation says it's v-shortkey.void but it's actually avoid. Had to look at the code to figure out what was going on.

Republish with NODE_ENV=production

Hi,

I noticed that the build of vue-shortkey include the sourcemaps. These should not be there. Could you recompile the bundle with NODE_ENV=production and republish your package ?

Thanks !

Using without CommonJS or webpack

Is it possible to use this plugin without webpack/commonJS?
I have a project where Vue JS is being used as standalone. Is there a way to use this plugin in a setup like that ?

e.g.,

<script src="/vendor/redprint/vendor/vue/vue.min.js"></script>
<script>
        var app = new Vue({
        .....
        .....

Thanks!

Fallback to click event handler?

If the shortcut is applied to a button / element with a click event, it would be nice to fallback to triggering the click handler if not shortkey event handler is declared.

Table shortkey

Hello @iFgR and πŸ‘ πŸ‘ πŸ‘ for this package

Just wondering, would you recommend a way to use shortkey on a long table with inputs on each row ?
Something like @shortkey="['ctrl', 'n']" to focus on next input and @shortkey="['ctrl', 'p']" to focus on previous input ?

Thank you

It doesn't work on component

Hi, this plugin is good!!

But I found a problem.

It works:
<div v-shortkey="['ctrl', 'p']" @shortkey="test"></div>

It doesn't work:
<my-component v-shortkey="['ctrl', 'p']" @shortkey="test"></my-component>

Is there any way to solve the issue?

Key sequences (Konami code)

Does this plugin support a sequence of keys to activate a shortcut? for example if I hit "up up down down" in order can this be detected as a single hotkey?

Question: How to add shortcut to Vue Router Link?

I'm trying to add a shortcut to a vue router link but I can't figure out what I need to do to get it working:

<router-link v-shortkey.once="['ctrl', 'shift', 't']" @shortkey="navigate" to="/items/add">
   Add Item                                                   
</router-link>

The "navigate" method referenced in the "shortkey" event handler is never called. What do I need to do to get this to work?

Using `push` doesn't emit key release when another modifier key is pressed [demo] [bug]

I am using vue-shortkey to track whether the Alt key is pressed. It works perfectly, but not if you press another modifier key like Shift or Control. For example:

βœ”οΈ Alt (press) -> emit -> Alt (release) -> emit
βœ”οΈ Alt (press) -> emit -> Ctrl (press) -> Ctrl (release) -> Alt (release) -> emit
❌ Alt (press) -> emit -> Ctrl (press) -> Alt (release) -> does not emit -> Ctrl (release)
❌ Shift (press) -> Alt (press) -> does not emit -> Alt (release) -> does not emit -> Shift (release)

Check this fiddle for a demo (make sure to focus the results panel). If you press Alt, then Ctrl and release Alt, the boolean value no longer displays whether the alt key is pressed, but rather - if it's released. That's because the release event for Alt is lost.


Browser:
Name: Google Chrome
Version: 72.0.3626.109 (Official Build) (64-bit)

OS:
Name: Microsoft Windows 10 Home
Version: 10.0.17134 Build 17134

Keyboard:
Name: Enhanced (101- or 102-key)
Description: Standard PS/2 Keyboard
Layout: 00000409

Binding to an component?

Hey,

I'm not sure this is the right place to ask this but why do I need to add it to a button or div?
Is there a way to add a listener for the same keys shortcuts without binding it to an html componant?

Really cool plugin btw (just discovered it)

Thanks!

How to bind '?'

I'm having trouble binding "?". I tried ['?'] and ['shift', '/'] with no luck. How can I bind to this combination ?

Also is it possible to bind two key combinations to one srcKey e.g. I want to have 'help' invoked by 'h' or by '?'

Check the function keys

Check if the function keys are mapped.
Keys like volume up, volume down stop, play, pause and so on...

shortkey works globally instead of on an element

I set up code like <button v-shortkey="['esc']" @shortkey="() => { console.log('esc') }">test</button>
but esc become catching all over the page.
I have several shortkeys over the page and don't want to block them all over some element, only particular one. What I do wrong?

Dist is outdated

The dist build has not been updated for the last version bump, i.e. v3.1.2 has the same dist build as v.3.1.3. Furthermore, v3.1.3 has been tagged on npm but there is no corresponding tag on github.

Add additional keys (space, pgUp, pgDown)

Hello, was wondering if you would support the addition of new keys. Space is a very useful one to play and pause video. There are some presentation remotes that use Page Up and Page Down as previous/next buttons, so they would be useful as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.