{"id":16483446,"url":"https://github.com/wusb/digital-keyboard","last_synced_at":"2025-04-13T05:30:54.914Z","repository":{"id":57197768,"uuid":"132836537","full_name":"wusb/digital-keyboard","owner":"wusb","description":"⌨️ Digital Keyboard 数字键盘 ","archived":false,"fork":false,"pushed_at":"2018-11-13T09:01:41.000Z","size":174,"stargazers_count":277,"open_issues_count":2,"forks_count":46,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-10T15:58:14.159Z","etag":null,"topics":["digital","digital-keyboard","digitalkeyboard","keyboard","mobile-keyboards"],"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/wusb.png","metadata":{"files":{"readme":"README-zh_CN.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":"2018-05-10T02:16:08.000Z","updated_at":"2024-09-27T01:14:56.000Z","dependencies_parsed_at":"2022-09-14T03:11:26.384Z","dependency_job_id":null,"html_url":"https://github.com/wusb/digital-keyboard","commit_stats":null,"previous_names":["simbawus/digital-keyboard","simbawus/digitalkeyboard"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wusb%2Fdigital-keyboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wusb%2Fdigital-keyboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wusb%2Fdigital-keyboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wusb%2Fdigital-keyboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wusb","download_url":"https://codeload.github.com/wusb/digital-keyboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670310,"owners_count":21142895,"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":["digital","digital-keyboard","digitalkeyboard","keyboard","mobile-keyboards"],"created_at":"2024-10-11T13:14:00.088Z","updated_at":"2025-04-13T05:30:54.878Z","avatar_url":"https://github.com/wusb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":" [English](README.md) | 简体中文\n\n# DigitalKeyboard 数字键盘\n\n[![Build Status](https://travis-ci.org/simbawus/digital-keyboard.svg?branch=master)](https://travis-ci.org/simbawus/digital-keyboard)\n[![Coverage Status](https://coveralls.io/repos/github/simbawus/digital-keyboard/badge.svg?branch=master)](https://coveralls.io/github/simbawus/digital-keyboard?branch=master)\n[![npm](https://img.shields.io/npm/v/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![npm](https://img.shields.io/npm/dt/digital-keyboard.svg)](https://www.npmjs.com/package/digital-keyboard)\n[![GitHub license](https://img.shields.io/github/license/simbawus/digital-keyboard.svg)](https://github.com/simbawus/digital-keyboard/blob/master/LICENSE)\n\n- 原生js开发、不依赖任何框架和库的轻量级移动端数字键盘\n- 支持身份证、手机号、整数、小数多类型输入\n- API简洁，非常好上手\n- 开发总结：[从0开始发布一个无依赖、高质量的npm](https://github.com/simbawus/blog/issues/12)\n\n[![Example](https://i.loli.net/2018/05/16/5afc5086957b3.gif)](https://i.loli.net/2018/05/16/5afc5086957b3.gif)\n\n## 键盘类型\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003cimg width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360a4c21.jpg\"\u003e\n        \u003cp\u003e小数\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003cimg width=\"240px\" src=\"https://i.loli.net/2018/05/17/5afc59314b61c.jpg\"\u003e\n        \u003cp\u003e整数/手机号\u003c/p\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\" valign=\"middle\"\u003e\n        \u003cimg width=\"240px\" src=\"https://i.loli.net/2018/05/16/5afc5360c635f.jpg\"\u003e\n        \u003cp\u003e身份证\u003c/p\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## 属性\n\n| Property      | Type     | Default | Description                              |\n| :------------ | :------- | :------ | :--------------------------------------- |\n| el            | DOM      |         | 键盘父节点                                    |\n| className     | String   |         | 外部传入可控制键盘样式的class                        |\n| type          | String   | decimal | 键盘类型：decimal小数，integer整数，phone手机号，idcard身份证 |\n| language      | String   | chinese | 语言：chinese，english                         |\n| inputValue    | Function |         | 键盘输入返回值                                  |\n| integerDigits | Number   |         | 限制整数位数                                   |\n| decimalDigits | Number   |         | 限制小数位数                                   |\n\n## 开始上手\n\n### 安装\n\n```shell\nyarn add digital-keyboard --dev\n```\n\n### 使用示例\n\n- **原生 JavaScript**\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"author\" content=\"吴胜斌,simbawu\"\u003e\n  \u003ctitle\u003e数字键盘\u003c/title\u003e\n  \u003cstyle\u003e\n    .container {\n      color: #333;\n    }\n  \u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cdiv id=\"values\"\u003e\u003c/div\u003e\n  \u003cdiv id=\"app\"\u003e\u003c/div\u003e\n  \u003cscript src=\"./digitalKeyboard.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n```javascript\n//digitalKeyboard.js\nimport DigitalKeyboard from 'digital-keyboard';\n\nfunction inputValue(value){\n  console.log(value); //DigitalKeyboard return value\n  document.querySelector('#values').innerHTML = value;\n}\n\nnew DigitalKeyboard(\n    {\n        el: document.querySelector('#app'),\n        type: 'idcard',\n        className: 'container',\n        inputValue: inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n    }\n);\n```\n\n- **React**\n\n```jsx\nimport React from 'react';\nimport DigitalKeyboard from \"digital-keyboard\";\nimport s from './digitalKeyboard.scss;\n\nclass KeyboardPage extends React.Component {\n\n  constructor(){\n    super();\n\n    this.inputValue = this.inputValue.bind(this);\n    this._renderKeyboard = this._renderKeyboard.bind(this);\n  }\n\n  componentDidMount(){\n    this._renderKeyboard();\n  }\n\n  inputValue(value){\n    console.log(value); //DigitalKeyboard return value\n  }\n\n  _renderKeyboard(){\n    return new DigitalKeyboard (\n      {\n        el: this.refs.digitalKeyboard,\n        className: s.container,\n        type: 'number',\n        inputValue: this.inputValue,\n        integerDigits: 4,\n        decimalDigits: 2\n      }\n    );\n  }\n\n  render(){\n    return (\n      \u003cdiv ref='digitalKeyboard'\u003e\u003c/div\u003e\n    )\n  }\n}\n\nexport default KeyboardPage;\n```\n\n- **Vue**\n\n```js\n\u003ctemplate\u003e\n  \u003cdiv\u003e\u003c/div\u003e\n\u003c/template\u003e\n\u003cstyle scoped lang=\"less\"\u003e\n    .container {\n        color: #333;\n    }\n\u003c/style\u003e\n\u003cscript\u003e\nimport DigitalKeyboard from \"digital-keyboard\";\nexport default {\n  mounted () {\n    this._renderDigitalKeyboard();\n  },\n  methods: () {\n    _renderDigitalKeyboard() {\n    \treturn new DigitalKeyboard (\n          {\n            el: this.$el,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n    },\n\n    inputValue(value) {\n      console.log(value); //DigitalKeyboard return value\n    }\n  }\n}\n\u003c/script\u003e\n```\n- **Angular**\n\n```typescript\n// Online-demo: https://stackblitz.com/edit/angular-hkexnq\nimport { Component, ViewChild, OnInit, ViewEncapsulation} from '@angular/core';\nimport DigitalKeyboard from \"digital-keyboard\";\n\n@Component({\n  selector: 'my-app',\n  template: `\n   \u003cdiv #keyboard\u003e\u003c/div\u003e\n  `,\n  styles: [`\n    .container {\n        color: #333;\n    }\n  `],\n  encapsulation: ViewEncapsulation.None\n})\nexport class AppComponent  implements OnInit{\n\n  @ViewChild('keyboard') keyboard;\n\n  ngOnInit(){\n    this._renderDigitalKeyboard();\n  }\n\n  _renderDigitalKeyboard(){\n    return new DigitalKeyboard (\n          {\n            el: this.keyboard.nativeElement,\n            className: 'container',\n            type: 'number',\n            inputValue: this.inputValue,\n            integerDigits: 4,\n            decimalDigits: 2\n          }\n        );\n  }\n\n  inputValue(value) {\n    console.log(value); //DigitalKeyboard return value\n  }\n}\n```\n\n## 如何贡献\n\n欢迎每个人为这个项目做出贡献。可以从查看我们[未解决的问题](https://github.com/simbawus/DigitalKeyboard/issues)、[提交新问题](https://github.com/simbawus/DigitalKeyboard/issues/new?labels=bug)或[提出新功能](https://github.com/simbawus/DigitalKeyboard/issues/new?labels=enhancement)入手，参与讨论投票您喜欢或不喜欢的问题。\n\n## 开源证书\n\n[**The MIT License**](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwusb%2Fdigital-keyboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwusb%2Fdigital-keyboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwusb%2Fdigital-keyboard/lists"}