更新记录

1.0.2(2022-06-28)

新增按键过滤api,不想监听的按键可以过滤掉,例如返回键

1.0.1(2022-03-02)

1.新增关闭监听接口 XM_Scan_Module.scanStopMonitor()


平台兼容性

Android Android CPU类型 iOS
适用版本区间:4.4 - 11.0 armeabi-v7a:支持,arm64-v8a:支持,x86:支持 ×

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


基本用法

在 js 中引入

const XM_Scan_Module = uni.requireNativePlugin('XM-Scan-Module');
// 设置过滤 设置过滤后的按键将不在监听 将需要过滤键值传给接口 如下示例
    let skip = '4' //过滤单个按键
        skip = '4,122,45' //过滤多个按键
        XM_Scan_Module.scanSetSkip(skip)

// 开启监听
XM_Scan_Module.scanStartMonitor(res => {
        console.log(res); 
        // 返回值{"code":1,"mKeyCode":60}
    })
//关闭监听
XM_Scan_Module.scanStopMonitor()

文档说明

接口名 参数 类型 说明
scanSetSkip skip string 需要过滤的按键,如:
'4'就是过滤键值为4的按键,
多个按键用逗号隔开如'4,5,6'
scanStartMonitor res function 开启监听并接受按键回调
返回值就是按键值
scanStopMonitor 关闭监听

具体用法看上方的基本用法或者下载示例项目查看具体写法

对应的键值参考,如有需求自行更改,仅作参考

const keyBoardVal = [
    {
        maxV: 'ESC',
        minV: 'esc',
        keyCode: 111
    },
    {
        maxV: 'F1',
        minV: 'f1',
        keyCode: 131
    },
    {
        maxV: 'F2',
        minV: 'f2',
        keyCode: 132
    },
    {
        maxV: 'F3',
        minV: 'f3',
        keyCode: 133
    },
    {
        maxV: 'F4',
        minV: 'f4',
        keyCode: 134
    },
    {
        maxV: 'F5',
        minV: 'f5',
        keyCode: 135
    },
    {
        maxV: 'F6',
        minV: 'f6',
        keyCode: 136
    },
    {
        maxV: 'F7',
        minV: 'f7',
        keyCode: 137
    },
    {
        maxV: 'F8',
        minV: 'f8',
        keyCode: 138
    },
    {
        maxV: 'F9',
        minV: 'f9',
        keyCode: 139
    },
    {
        maxV: 'F10',
        minV: 'f10',
        keyCode: 140
    },
    {
        maxV: 'F11',
        minV: 'f11',
        keyCode: 141
    },
    {
        maxV: 'F12',
        minV: 'f12',
        keyCode: 142
    },
    {
        maxV: 'SCROLL LOCK',
        minV: 'scroll lock',
        keyCode: 116
    },
    {
        maxV: 'PAUSE BREAK',
        minV: 'pause break',
        keyCode: 121
    },
    {
        maxV: 'DEL',
        minV: 'del',
        keyCode: 112
    },
    {
        maxV: 'END',
        minV: 'end',
        keyCode: 123
    },
    {
        maxV: 'PGDN',
        minV: 'pgdn',
        keyCode: 93
    },
    {
        maxV: '`',
        minV: '`',
        keyCode: 68
    },
    {
        maxV: '0',
        minV: '0',
        type: 'digit',
        keyCode: 7
    },
    {
        maxV: '1',
        minV: '1',
        type: 'digit',
        keyCode: 8
    },
    {
        maxV: '2',
        minV: '2',
        type: 'digit',
        keyCode: 9
    },
    {
        maxV: '3',
        minV: '3',
        type: 'digit',
        keyCode: 10
    },
    {
        maxV: '4',
        minV: '4',
        type: 'digit',
        keyCode: 11
    },
    {
        maxV: '5',
        minV: '5',
        type: 'digit',
        keyCode: 12
    },
    {
        maxV: '6',
        minV: '6',
        type: 'digit',
        keyCode: 13
    },
    {
        maxV: '7',
        minV: '7',
        type: 'digit',
        keyCode: 14
    },
    {
        maxV: '8',
        minV: '8',
        type: 'digit',
        keyCode: 15
    },
    {
        maxV: '9',
        minV: '9',
        type: 'digit',
        keyCode: 16
    },
    {
        maxV: '-',
        minV: '-',
        keyCode: 69
    },
    {
        maxV: '=',
        minV: '=',
        keyCode: 70
    },
    {
        maxV: 'BACK',
        minV: 'back',
        keyCode: 67
    },
    {
        maxV: 'INSERT',
        minV: 'insert',
        keyCode: 124
    },
    {
        maxV: 'HOME',
        minV: 'home',
        keyCode: 122
    },
    {
        maxV: 'PGUP',
        minV: 'pgup',
        keyCode: 92
    },
    {
        maxV: 'TAB',
        minV: 'tab',
        keyCode: 61
    },
    {
        maxV: '[',
        minV: '[',
        keyCode: 71
    },
    {
        maxV: ']',
        minV: ']',
        keyCode: 72
    },
    {
        maxV: '\\',
        minV: '\\',
        keyCode: 73
    },
    {
        maxV: 'CAPSLOCK',
        minV: 'capslock',
        keyCode: 115
    },
    {
        maxV: ';',
        minV: ';',
        keyCode: 74
    },
    {
        maxV: "'",
        minV: "'",
        keyCode: 75
    },
    {
        maxV: "ENTER",
        minV: "enter",
        keyCode: 66
    },
    {
        maxV: "SHIFT",
        minV: "shift",
        keyCode: 59
    },
    {
        maxV: ",",
        minV: ",",
        keyCode: 55
    },
    {
        maxV: ".",
        minV: ".",
        keyCode: 56
    },
    {
        maxV: "/",
        minV: "/",
        keyCode: 76
    },
    {
        maxV: "SHIFT",
        minV: "shift",
        keyCode: 60
    },
    {
        maxV: "CTRL",
        minV: "ctrl",
        keyCode: 113
    },
    {
        maxV: "ALT",
        minV: "alt",
        keyCode: 57
    },
    {
        maxV: " ",
        minV: " ",
        keyCode: 62
    },
    {
        maxV: "ALT",
        minV: "alt",
        keyCode: 58
    },
    {
        maxV: "CTRL",
        minV: "ctrl",
        keyCode: 114
    },
    {
        maxV: "A",
        minV: "a",
        keyCode: 29
    },
    {
        maxV: "B",
        minV: "b",
        keyCode: 30
    },
    {
        maxV: "C",
        minV: "c",
        keyCode: 31
    },
    {
        maxV: "D",
        minV: "d",
        keyCode: 32
    },
    {
        maxV: "E",
        minV: "e",
        keyCode: 33
    },
    {
        maxV: "F",
        minV: "f",
        keyCode: 34
    },
    {
        maxV: "G",
        minV: "g",
        keyCode: 35
    },
    {
        maxV: "H",
        minV: "h",
        keyCode: 36
    },
    {
        maxV: "I",
        minV: "i",
        keyCode: 37
    },
    {
        maxV: "J",
        minV: "j",
        keyCode: 38
    },
    {
        maxV: "K",
        minV: "k",
        keyCode: 39
    },
    {
        maxV: "L",
        minV: "l",
        keyCode: 40
    },
    {
        maxV: "M",
        minV: "m",
        keyCode: 41
    },
    {
        maxV: "N",
        minV: "n",
        keyCode: 42
    },
    {
        maxV: "O",
        minV: "o",
        keyCode: 43
    },
    {
        maxV: "P",
        minV: "p",
        keyCode: 44
    },
    {
        maxV: "Q",
        minV: "q",
        keyCode: 45
    },
    {
        maxV: "R",
        minV: "r",
        keyCode: 46
    },
    {
        maxV: "S",
        minV: "s",
        keyCode: 47
    },
    {
        maxV: "T",
        minV: "t",
        keyCode: 48
    },
    {
        maxV: "U",
        minV: "u",
        keyCode: 49
    },
    {
        maxV: "V",
        minV: "v",
        keyCode: 50
    },
    {
        maxV: "W",
        minV: "w",
        keyCode: 51
    },
    {
        maxV: "X",
        minV: "x",
        keyCode: 52
    },
    {
        maxV: "Y",
        minV: "y",
        keyCode: 53
    },
    {
        maxV: "Z",
        minV: "z",
        keyCode: 54
    },
    {
        maxV: "UP",
        minV: "up",
        keyCode: 19
    },
    {
        maxV: "DOWN",
        minV: "down",
        keyCode: 20
    },
    {
        maxV: "LEFT",
        minV: "left",
        keyCode: 21
    },
    {
        maxV: "RIGHT",
        minV: "right",
        keyCode: 22
    },
    {
        maxV: "NUM LOCK",
        minV: "num lock",
        keyCode: 143
    },
    {
        maxV: "/",
        minV: "/",
        keyCode: 154
    },
    {
        maxV: "*",
        minV: "*",
        keyCode: 155
    },
    {
        maxV: "-",
        minV: "-",
        keyCode: 156
    },
    {
        maxV: "+",
        minV: "+",
        keyCode: 157
    },
    {
        maxV: "ENTER",
        minV: "enter",
        keyCode: 160
    },
    {
        maxV: ".",
        minV: ".",
        keyCode: 158
    },
    {
        maxV: "0",
        minV: "0",
        keyCode: 144
    },
    {
        maxV: "1",
        minV: "1",
        keyCode: 145
    },
    {
        maxV: "2",
        minV: "2",
        keyCode: 146
    },
    {
        maxV: "3",
        minV: "3",
        keyCode: 147
    },
    {
        maxV: "4",
        minV: "4",
        keyCode: 148
    },
    {
        maxV: "5",
        minV: "5",
        keyCode: 149
    },
    {
        maxV: "6",
        minV: "6",
        keyCode: 150
    },
    {
        maxV: "7",
        minV: "7",
        keyCode: 151
    },
    {
        maxV: "8",
        minV: "8",
        keyCode: 152
    },
    {
        maxV: "9",
        minV: "9",
        keyCode: 153
    },
]

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问