GithubHelp home page GithubHelp logo

lbsdev / vue-touch-keyboard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from icebob/vue-touch-keyboard

0.0 1.0 0.0 91 KB

Virtual keyboard component for Vue.js 2.x. Designed to Raspberry Pi Touch Display

License: MIT License

JavaScript 41.26% Vue 55.13% HTML 1.60% CSS 2.01%

vue-touch-keyboard's Introduction

vue-touch-keyboard NPM version VueJS v2.x compatible

Virtual keyboard component for Vue.js v2.x. Designed to Raspberry Pi Touch Display

Codacy Badge Build Status Coverage Status NPMS.io score

Dependency Status devDependency Status Downloads

Demo

JSFiddle demo

Screenshot

Features

  • 3 built-in layouts, but you can create custom layouts
  • no external dependencies
  • full responsive
  • customizable styles
  • ...etc

Installation

NPM

You can install it via NPM.

$ npm install vue-touch-keyboard

Manual

Download zip package and unpack and add the vue-touch-keyboard.css and vue-touch-keyboard.js file to your project from dist folder.

https://github.com/icebob/vue-touch-keyboard/archive/master.zip

Usage

<template>
  <div>
    <input type="text" placeholder="Text input" @focus="show" data-layout="normal" />
    <vue-touch-keyboard v-if="visible", :layout="layout", :cancel="hide", :accept="accept", :input="input" />
  </div>
</template>

<script>
  import VueTouchKeyboard from "vue-touch-keyboard";
  import style from "vue-touch-keyboard/dist/vue-touch-keyboard.css"; // load default style

  Vue.use(VueTouchKeyboard);

  export default {
    data: {
      visible: false,
      layout: "normal",
      input: null,
      options: {
        useKbEvents: false
      }
    },

    methods: {
        accept(text) {
          alert("Input text: " + text);
          this.hide();
        },

        show(e) {
          this.input = e.target;
          this.layout = e.target.dataset.layout;

          if (!this.visible)
            this.visible = true
        },

        hide() {
          this.visible = false;
        }
    }
  }
</script>

Properties

Property Default Accepted values Description
input required HTMLInputElement The target input HTML element
layout required String or Object Layout of keys. If you are using the built-in layouts, you can set as the name of the layout. If you want to use custom layout, you need to set a layout Object.
accept null Function Event handler. Fired when the "Accept/Close" button pressed.
cancel null Function Event handler. Fired when the "Cancel" button pressed.
change null Function Event handler. Fired when the input value changed.
next null Function Event handler. Fired when the "Next" button pressed or the length of the value of the input reached the maxLength of the input
options {} Object Functional options.

Options

Option Default Accepted values Description
useKbEvents false boolean If true, the component will generate a keypress event and trigger it. If it returns with false, it won't insert the new character.

Built-in layouts

  • normal - Normal full layout. Similar as real keyboard layouts
  • numeric - Only for numbers
  • compact - Compact layout. Similar as mobile phone keyboard layouts

Development

This command will start a webpack-dev-server with content of dev folder.

npm run dev

Build

This command will build a distributable version in the dist directory.

npm run build

Test

npm test

Contribution

Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.

License

vue-touch-keyboard is available under the MIT license.

Contact

Copyright (C) 2016 Icebob

@icebob @icebob

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.