Giter Site home page Giter Site logo

ecrmnn / meta-ctrl-enter Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 3 KB

Trigger Vue methods by pressing cmd+enter, windows+enter or ctrl+enter

Home Page: https://npmjs.com/meta-ctrl-enter

License: MIT License

JavaScript 100.00%
vue vuejs vue-directive eventlistener

meta-ctrl-enter's Introduction

meta-ctrl-enter

Trigger Vue methods by pressing cmd+enter, ctrl+enter or windows key+enter

npm version npm downloads npm license

Installation

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

// 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);
<template>
    <input type="text" v-meta-ctrl-enter="submit">
</template>

<script>
    export default {
      methods: {
        submit(event) {
          // This will be triggered when pressing;
          // cmd + enter
          // windows key + enter
          // ctrl + enter
          console.log('triggered ...', event);
        }
      }
    }
</script>

License

MIT © Daniel Eckermann

meta-ctrl-enter's People

Contributors

ecrmnn avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.