Socket
Socket
Sign inDemoInstall

virtual-keyboard-react

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    virtual-keyboard-react

keyBoard base on React , support hand write✒


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
267 kB
Created
Weekly downloads
 

Readme

Source

Logo

Simple, Fast Key-Board.

keyBoard base on React , support hand write.

gzip size No dependencies Github Current version Npm Current version

Other versions

They have the same function as the React version

Overview

Demo Demo Demo


关于

特性 🎉

  • 支持多达五种键盘模式
  • 支持自定义主题色
  • 已集成丰富的中文字库
  • 支持急速识别的手写能力
  • react 组件开箱即用

支持环境

IE / Edge EdgeFirefoxFirefoxChromeChromeSafariSafariOperaOpera
Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

安装

使用 npm 或 yarn 安装

$ npm install virtual-keyboard-react --save
$ yarn add virtual-keyboard-react --save

如果你的网络环境不佳,推荐使用 cnpm

使用

组件引入

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import "virtual-keyboard-react/keyboard.min.css";
import KeyBoard from "virtual-keyboard-react";

const App:React.FC = () => {
  return (
    {/* 注册键盘的输入框 */}
    <input data-mode />
    {/* 键盘 */}
    <KeyBoard
        modal
        onChange={value => {
          console.log('value', value);
        }}
        keyChange={value => {
          console.log('value', value);
        }}
      />
  )
}

ReactDOM.render(<App />, document.getElementById('root'));

配置参数

Input 标签属性

属性说明类型可选值默认值
data-mode弹出输入法的类型:
en 英文小写
number数字
symbol 标点
handwrite 手写
不传 默认中文
Stringen
number
symbol
handwrite
default as *
data-prop注册的输入框的类型String*

Props 属性

参数说明默认值类型是否必须版本
autoChange当前注册并聚焦的输入框是否自动更新valuetruebooleanv1.0.0+
color主题色#eaa050stringv1.0.0+
modeList键盘渲染模式列表,若不传 handApi 则不会出现手写板["handwrite", "symbol"]string[]v1.0.0+
blurHide是否当前输入框 blur 事件触发隐藏truebooleanv1.0.0+
showHandleBar是否显示拖拽句柄truebooleanv1.0.0+
dargHandleText拖拽句柄提示文字stringv1.0.0+
modal是否显示遮罩层falsebooleanv1.0.0+
closeOnClickModal是否点击遮罩层隐藏键盘truebooleanv1.0.0+
handApi手写识别接口,若不传则无法切换手写模块stringv1.0.0+
animateClass键盘显隐动画,内置 slide 动画,如若需要其他动画,可传入相应类名自定义动画stringv1.0.0+
transitionTime键盘显隐动画所需时间300numberv1.0.0+

Events

参数说明类型版本
keyChange按键触发事件,第一个参数为当前触发的按键的标识,第二个参数为当前聚焦输入框的props值,若没有则直接返回当前聚焦的input元素(v1.0.2版本之后)(value: string,prop:string|HTMLInputElement) => voidv1.0.0+
onChangevalue改变事件,第一个参数为当前最新通过键盘输入的值,第二个参数为当前聚焦输入框的props值,若没有则直接返回当前聚焦的input元素(v1.0.2版本之后)(value: string,prop:string|HTMLInputElement) => voidv1.0.0+
closed键盘关闭事件() => voidv1.0.0+
modalClick遮罩点击事件() => voidv1.0.0+

Component Event

方法名说明类型版本
reSignUp重新给 input 注册绑定键盘,当页面有新的 input 标签出现时调用此方法eventv1.0.0+
getCurrentInput获取当前聚焦的输入框()=> HTMLInputElement | nullv1.0.2+
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import "virtual-keyboard-react/keyboard.min.css";
import KeyBoard, { IKeyBoardRef } from "virtual-keyboard-react";

const App:React.FC = () => {
  const ref = React.useRef<IKeyBoardRef>();

  // .... 相关逻辑
  // 重新给键盘注册输入框
  if (ref.current) {
      ref.current.reSignUp();
      const currentInput = ref.current.getCurrentInput();
      console.log('currentInput', value);
  }
    
  return (
    {/* 注册键盘的输入框 */}
    <input data-mode />
    {/* 键盘 */}
    <KeyBoard
        modal
        ref={ref}
        onChange={value => {
          console.log('value', value);
        }}
        keyChange={value => {
          console.log('value', value);
        }}
      />
  )
}

ReactDOM.render(<App />, document.getElementById('root'));

其他说明

  • 有问题欢迎提交 Issue。
  • 本项目为作者一人维护,精力有限,有限解决重大 bug,望理解。
  • 用于生产环境,请使用 release 版本代码

Keywords

FAQs

Last updated on 26 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc