
Description
vue-global-events is a Vue 3 component that registers global event listeners, such as keyboard shortcuts, the way you would listen to events on a component. Vue's event modifiers only work on DOM elements, and this component extends that to listeners on the whole document, or on the window. You use it as a component, and when it is removed or hidden with a v-if, its listeners are removed too, so you do not need to clean them up yourself. It works with server-side rendering. The target prop chooses between document and window by name. It is not reactive, so it should be a static value, or you give the component a key when it changes. A filter prop takes a function that can stop a handler from running, based on the event, the handler or the event name, for example to ignore key presses from an input. The README includes installation and usage steps and a demo. The Vue 3 version is the main branch, and the Vue 2 version is kept on the v1 branch.…
Highlights
- Global keyboard shortcuts as a component
- Target document or window
- Filter function to skip events
- Removed automatically with v-if
- Works with server-side rendering
Ratings & Reviews
No ratings yet
Be the first to rate vue-global-events.
People also visit
vue-global-events FAQ
What is vue-global-events?
A Vue 3 component for listening to events on the document or window, such as keyboard shortcuts.
Does it support Vue 2?
The main branch is for Vue 3. The README points to the v1 branch for Vue 2.
How do I stop a handler from running?
Pass a filter function that returns false for the events you want to ignore.
Does it work with server-side rendering?
Yes, the README says it works with SSR.
Can I turn the listeners on and off?
Yes. Toggle the component with a single v-if.
What are the best vue-global-events alternatives?
Popular alternatives to vue-global-events include vue-slider-component, @vuepic/vue-datepicker and vue3-apexcharts. See all vue-global-events alternatives





















