https://github.com/ecrmnn/meta-ctrl-enter
Trigger Vue methods by pressing cmd+enter, windows+enter or ctrl+enter
https://github.com/ecrmnn/meta-ctrl-enter
eventlistener vue vue-directive vuejs
Last synced: 3 months ago
JSON representation
Trigger Vue methods by pressing cmd+enter, windows+enter or ctrl+enter
- Host: GitHub
- URL: https://github.com/ecrmnn/meta-ctrl-enter
- Owner: ecrmnn
- License: mit
- Created: 2017-05-08T19:30:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-09T16:50:43.000Z (about 8 years ago)
- Last Synced: 2025-03-19T07:52:55.838Z (3 months ago)
- Topics: eventlistener, vue, vue-directive, vuejs
- Language: JavaScript
- Homepage: https://npmjs.com/meta-ctrl-enter
- Size: 2.93 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# meta-ctrl-enter
> Trigger Vue methods by pressing cmd+enter, ctrl+enter or windows key+enter[](http://badge.fury.io/js/meta-ctrl-enter)
[](http://badge.fury.io/js/meta-ctrl-enter)
[](http://badge.fury.io/js/meta-ctrl-enter)### Installation
```bash
npm install meta-ctrl-enter --save
```### Why?
Why not use ``@keydown.meta.enter="myMethod"``?Tl;dr: On Windows keyboards, ``meta`` is the windows key (⊞), and this is not a "natural" modifier key.
By using ``v-meta-ctrl-enter`` you'll be able to use ``ctrl+enter`` which is a widley used modifier key.From Vue.js documentation:
> On Macintosh keyboards, meta is the command key (⌘). On Windows keyboards, meta is the windows key (⊞). On Sun Microsystems keyboards, meta is marked as a solid diamond (◆). On certain keyboards, specifically MIT and Lisp machine keyboards and successors, such as the Knight keyboard, space-cadet keyboard, meta is labeled “META”. On Symbolics keyboards, meta is labeled “META” or “Meta”.### Usage
```javascript
// Load using CommonJS syntax
const Vue = require('vue');
const MetaCtrlEnter = require('meta-ctrl-enter');
Vue.use(MetaCtrlEnter);// Load using ES6 syntax
import Vue from 'vue';
import MetaCtrlEnter from 'meta-ctrl-enter';
Vue.use(MetaCtrlEnter);
``````html
export default {
methods: {
submit(event) {
// This will be triggered when pressing;
// cmd + enter
// windows key + enter
// ctrl + enter
console.log('triggered ...', event);
}
}
}```
### License
MIT © [Daniel Eckermann](http://danieleckermann.com)