{"id":13829588,"url":"https://github.com/viclm/numeric-keyboard","last_synced_at":"2025-04-13T07:46:29.803Z","repository":{"id":25742427,"uuid":"106380954","full_name":"viclm/numeric-keyboard","owner":"viclm","description":"Number keyboard for mobile browsers","archived":false,"fork":false,"pushed_at":"2022-12-09T14:34:47.000Z","size":1422,"stargazers_count":363,"open_issues_count":25,"forks_count":73,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-13T07:46:23.332Z","etag":null,"topics":["angular","javascript","keyboard","preact","react","vue"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viclm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-10T07:07:26.000Z","updated_at":"2025-02-25T02:54:08.000Z","dependencies_parsed_at":"2023-01-14T03:30:44.738Z","dependency_job_id":null,"html_url":"https://github.com/viclm/numeric-keyboard","commit_stats":null,"previous_names":["viclm/vue-numeric-keyboard"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viclm%2Fnumeric-keyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viclm%2Fnumeric-keyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viclm%2Fnumeric-keyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viclm%2Fnumeric-keyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viclm","download_url":"https://codeload.github.com/viclm/numeric-keyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681474,"owners_count":21144698,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","javascript","keyboard","preact","react","vue"],"created_at":"2024-08-04T10:00:40.174Z","updated_at":"2025-04-13T07:46:29.743Z","avatar_url":"https://github.com/viclm.png","language":"JavaScript","readme":"# Numeric Keyboard\n\n[![Build Status](https://travis-ci.org/viclm/numeric-keyboard.svg?branch=master)](https://travis-ci.org/viclm/numeric-keyboard)\n[![npm package](https://img.shields.io/npm/v/numeric-keyboard.svg)](https://www.npmjs.org/package/numeric-keyboard)\n\nA custom virtual numeric keyboard works in mobile browsers. It contains a virtual input box which would invoke the numeric keyboard instead of system keyboard, the virtual input box supports many html5 standard properties and also has a nice cursor to make it behaves like native input element as much as possible.\nBesides, the numeric keyboard is a pluggable component can be used together with other input interfaces.\n\nThe numeric keyboard is created respectively for **Vanilla JavaScript**, **React**, **Angular** and **Vue**.\n\n\u003e for **React**, **Angular** and **Vue**, only the latest version is supported.\n\n:cn: [中文说明](https://github.com/viclm/numeric-keyboard/blob/master/docs/README.cn.md) :cn: :cn: :cn: :cn:\n\n![snapshot](https://raw.githubusercontent.com/viclm/numeric-keyboard/master/docs/demo.gif)\n\n## Table of contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Keyboard](#keyboard)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\nYou can install it via **Yarn**\n```shell\nyarn add numeric-keyboard\n```\n\nConfig **Webpack** to use the right version\n```javascript\nresolve: {\n  alias: {\n    // use Vue component for example\n    'numeric-keyboard$': 'numeric-keyboard/dist/numeric_keyboard.vue.js'\n  }\n},\n```\n\n\n## Usage\n\n#### Vanilla JavaScript\n```javascript\nimport { NumericInput } from 'numeric-keyboard'\nnew NumericInput({\n  type: 'number',\n  placeholder: 'touch to input',\n  onInput(value) {\n    ...\n  }\n}).mount('.input')\n```\n\n#### React\n```jsx\nimport { NumericInput } from 'numeric-keyboard'\nclass App extends React.Component {\n  input(val) {\n    ...\n  },\n  render() {\n    return \u003cdiv className=\"input\"\u003e\n      \u003clabel\u003eAmount: \u003c/label\u003e\n      \u003cNumericInput type=\"number\" placeholder=\"touch to input\" onInput={this.input.bind(this)} /\u003e\n    \u003c/div\u003e\n  }\n}\n```\n\n#### Angular\n```typescript\nimport { Component } from '@angular/core';\n@Component({\n  selector: 'app-root',\n  template: `\n    \u003cdiv className=\"input\"\u003e\n      \u003clabel\u003eAmount: \u003c/label\u003e\n      \u003cnumeric-input type=\"number\" placeholder=\"touch to input\" [(ngModel)]=\"amount\"\u003e\u003c/numeric-input\u003e\n    \u003c/div\u003e\n  `,\n})\nexport class AppComponent {\n  public amount: number | string = ''\n}\n```\n\n#### Vue\n```vue\n\u003ctemplate\u003e\n  \u003cdiv class=\"input\"\u003e\n    \u003clabel\u003eAmount: \u003c/label\u003e\n    \u003cNumericInput placeholder=\"touch to input\" v-model=\"amount\" /\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  import { NumericInput } from 'numeric-keyboard'\n  export default {\n    components: {\n      NumericInput\n    },\n    data() {\n      return {\n        amount: ''\n      }\n    }\n  }\n\u003c/script\u003e\n\n```\n\n### Options/Props\n\nAs a substitute for native input element, the input box supports most of the standard attributes, you can refer the HTML spec for details.\n\n```javascript\n// There are only two types: number and tel, the corresponding layout of keyboard would be invoked by default.\ntype: {\n  type:String,\n  default: 'number'\n},\nautofocus: {\n  type: Boolean,\n  default: false\n},\ndisabled: {\n  type: Boolean,\n  default: false\n},\nmaxlength: {\n  type: Number\n},\nname: {\n  type: String\n},\nplaceholder: {\n  type: String\n},\nreadonly: {\n  type: Boolean,\n  default: false\n},\nvalue: {\n  type: [String, Number]\n},\n// Passs a regexp string or function to limit the input.\nformat: {\n  type: [String, Function]\n},\n// change the layout of keyboard\nlayout: {\n type: [String, Array],\n default: 'number'\n},\n// change the label of keyboard enter key, use iconfont for icon.\nentertext: {\n type: String,\n default: 'enter'\n}\n```\n\n### Callback/Events\n\n#### `input`\nThe `input` event is emitted when the value of input changes. The first argument for the callback is the value of the input box rather than an event object from a native input element. A `onInput()` callback is used in vanilla javascript version.\n\n#### `enterpress`\nThe `enterpress` event is emitted when the enter key of keyboard is pressed.\n\n\n## Keyboard\n\nThe keyboard is a pluggable component which supports custom layout. In order to be able to work properly in a real scene, it usually needs to match an output interface.\n\n### Usage\n\n#### Vanilla JavaScript\n```javascript\nimport { NumericKeyboard } from 'numeric-keyboard'\nnew NumericKeyboard('.keyboard', {\n  layout: 'tel',\n  onPress(key) {\n    ...\n  }\n})\n```\n\n#### React\n```jsx\nimport { NumericKeyboard } from 'numeric-keyboard'\nclass App extends React.Component {\n  press(key) {\n    ...\n  }\n  render() {\n    return \u003cdiv className=\"keyboard\"\u003e\n      \u003cNumericKeyboard layout=\"tel\" onPress={this.press.bind(this)} /\u003e\n    \u003c/div\u003e\n  }\n}\n```\n\n#### Angular\n```typescript\nimport { Component } from '@angular/core';\n@Component({\n  selector: 'app-root',\n  template: `\n    \u003cdiv class=\"keyboard\"\u003e\n      \u003cnumeric-keyboard layout=\"tel\" (onPress)=\"press($event)\"\u003e\u003c/numeric-keyboard\u003e\n    \u003c/div\u003e\n  `,\n})\nexport class AppComponent {\n  press(key) {\n    ...\n  }\n}\n```\n\n#### Vue\n```vue\n\u003ctemplate\u003e\n   \u003cdiv class=\"keyboard\"\u003e\n     \u003cNumericKeyboard layout=\"tel\" @press=\"press\" /\u003e\n   \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  import { NumericKeyboard } from 'numeric-keyboard'\n  export default {\n    components: {\n      NumericKeyboard\n    },\n    methods: {\n      press(key) {\n        ...\n      }\n    }\n  }\n\u003c/script\u003e\n```\n\n### Options/Props\n\n```javascript\n// change the layout of keyboard\nlayout: {\n type: [String, Array],\n default: 'number'\n},\n// change the label of keyboard enter key, use iconfont for icon.\nentertext: {\n type: String,\n default: 'enter'\n}\n```\n\n#### `layout`\nThere are two built-in layouts called **number** and **tel** which can be used as a replacement of system keyboard.\nYou can still rearrange all the keys to create your own layout. The layout object is a two-dimension array which constructs a table layout, you can make table-specific operations like merging cells.\n\n##### number layout\n![number layout](https://raw.githubusercontent.com/viclm/numeric-keyboard/master/docs/snapshot_number.png)\n\n##### tel layout\n![tel layout](https://raw.githubusercontent.com/viclm/numeric-keyboard/master/docs/snapshot_tel.png)\n\n##### custom layout\n```javascript\n// code sample for the build-in number layout\nimport { keys } from 'numeric-keyboard'\n[\n  [\n    {\n      key: keys.ONE\n    },\n    {\n      key: keys.TWO\n    },\n    {\n      key: keys.THREE\n    },\n    {\n      key: keys.DEL,\n      rowspan: 2,\n    },\n  ],\n  [\n    {\n      key: keys.FOUR\n    },\n    {\n      key: keys.FIVE\n    },\n    {\n      key: keys.SIX\n    },\n  ],\n  [\n    {\n      key: keys.SEVEN\n    },\n    {\n      key: keys.EIGHT\n    },\n    {\n      key: keys.NINE\n    },\n    {\n      key: keys.ENTER,\n      rowspan: 2,\n    },\n  ],\n  [\n    {\n      key: keys.DOT\n    },\n    {\n      key: keys.ZERO\n    },\n    {\n      key: keys.ESC\n    },\n  ],\n]\n```\n\n### Callbacks/Events\n\n#### `press`\nthe `press` event is emitted with a key code when the key is pressed. The argument for the callback is the key just pressed. A `onPress()` callback is used in vanilla javascript version.\n\n#### `enterpress`\nThe `enterpress` event is emitted when the enter key of keyboard is pressed.\n\n\n## Contributing\nWelcome to contributing, the guidelines are being drafted.\n\n\n## License\nLicensed under the MIT license.\n","funding_links":[],"categories":["UI组件","Components \u0026 Libraries","Vue","UI Components [🔝](#readme)","UI Components"],"sub_categories":["杂","UI Components","组件","Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviclm%2Fnumeric-keyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviclm%2Fnumeric-keyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviclm%2Fnumeric-keyboard/lists"}