mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-02-03 00:06:50 +08:00
Compare commits
64 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3162cc80f8 | ||
|
|
de2100cb7b | ||
|
|
04a3c186f0 | ||
|
|
5fa612a923 | ||
|
|
9a34b6eb37 | ||
|
|
66fa632ca4 | ||
|
|
51d6d66fc6 | ||
|
|
84d2c45887 | ||
|
|
966bfd47db | ||
|
|
02d88bae10 | ||
|
|
6802c1f9dc | ||
|
|
b490481761 | ||
|
|
8795232092 | ||
|
|
ba20077e7a | ||
|
|
f175c1dcb8 | ||
|
|
abd2471119 | ||
|
|
d25b70fc3d | ||
|
|
d274abf755 | ||
|
|
922c865d0f | ||
|
|
5735215b0a | ||
|
|
d007a76fa0 | ||
|
|
d561c8b666 | ||
|
|
78cc636d32 | ||
|
|
5907eb3baa | ||
|
|
4e7ea1f687 | ||
|
|
4388f26cb6 | ||
|
|
2c524f82ff | ||
|
|
2911bb5022 | ||
|
|
3fe39dc9e3 | ||
|
|
ab9839f94f | ||
|
|
b4c21693bd | ||
|
|
7a647f16ab | ||
|
|
619991b4ba | ||
|
|
e7fa7fb1fd | ||
|
|
31fa3d0592 | ||
|
|
bcef967a20 | ||
|
|
267838c299 | ||
|
|
c5ad9d2240 | ||
|
|
8a865aed53 | ||
|
|
a0f603597c | ||
|
|
0a814d0a7b | ||
|
|
513db7f056 | ||
|
|
1d863c4f81 | ||
|
|
9443d6a91a | ||
|
|
f19bf3c933 | ||
|
|
55f96064e0 | ||
|
|
44e4d00111 | ||
|
|
13f80bdcbe | ||
|
|
17016588d6 | ||
|
|
a63e3cce76 | ||
|
|
46b1c9bfda | ||
|
|
f523d6ae51 | ||
|
|
68dfc94ea7 | ||
|
|
2274108619 | ||
|
|
7d5417ab2a | ||
|
|
1a29880ef8 | ||
|
|
319eaa22cf | ||
|
|
c8bafdb517 | ||
|
|
fb7008d04b | ||
|
|
69706bd8f6 | ||
|
|
ad4af7cde0 | ||
|
|
a0c24db9d2 | ||
|
|
f702184e15 | ||
|
|
45d2f5b50d |
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '11.2'
|
||||
- node
|
||||
install:
|
||||
- npm install -g codecov
|
||||
- npm install
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.21.0
|
||||
* simple-keyboard v2.23.0
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
@@ -8,5 +8,5 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/body,html{margin:0;padding:0}.simple-keyboard{font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;overflow:hidden;touch-action:manipulation}.simple-keyboard .hg-row{display:-webkit-flex;display:flex}.simple-keyboard .hg-row:not(:last-child){margin-bottom:5px}.simple-keyboard .hg-row .hg-button-container,.simple-keyboard .hg-row .hg-button:not(:last-child){margin-right:5px}.simple-keyboard .hg-row>div:last-child{margin-right:0}.simple-keyboard .hg-row .hg-button-container{display:-webkit-flex;display:flex}.simple-keyboard .hg-button{display:inline-block;-webkit-flex-grow:1;flex-grow:1;cursor:pointer}.simple-keyboard .hg-button span{pointer-events:none}.simple-keyboard.hg-theme-default{background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.simple-keyboard.hg-theme-default .hg-button{box-shadow:0 0 3px -1px rgba(0,0,0,.3);height:40px;border-radius:5px;box-sizing:border-box;padding:5px;background:#fff;border-bottom:1px solid #b5b5b5;cursor:pointer;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active{background:#e4e4e4}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.simple-keyboard.hg-theme-default .hg-button.hg-button-com{max-width:85px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton{background:rgba(5,25,70,.53);color:#fff}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}
|
||||
*/body,html{margin:0;padding:0}.simple-keyboard{font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;overflow:hidden;touch-action:manipulation}.simple-keyboard .hg-row{display:flex}.simple-keyboard .hg-row:not(:last-child){margin-bottom:5px}.simple-keyboard .hg-row .hg-button-container,.simple-keyboard .hg-row .hg-button:not(:last-child){margin-right:5px}.simple-keyboard .hg-row>div:last-child{margin-right:0}.simple-keyboard .hg-row .hg-button-container{display:flex}.simple-keyboard .hg-button{display:inline-block;flex-grow:1;cursor:pointer}.simple-keyboard .hg-button span{pointer-events:none}.simple-keyboard.hg-theme-default{background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.simple-keyboard.hg-theme-default .hg-button{box-shadow:0 0 3px -1px rgba(0,0,0,.3);height:40px;border-radius:5px;box-sizing:border-box;padding:5px;background:#fff;border-bottom:1px solid #b5b5b5;cursor:pointer;display:flex;align-items:center;justify-content:center}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active{background:#e4e4e4}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;align-items:center;display:flex;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.simple-keyboard.hg-theme-default .hg-button.hg-button-com{max-width:85px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton{background:rgba(5,25,70,.53);color:#fff}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}
|
||||
/*# sourceMappingURL=index.css.map */
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.21.0 (Non-minified build)
|
||||
* simple-keyboard v2.23.0 (Non-minified build)
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
@@ -8,4 +8,4 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/body,html{margin:0;padding:0}.simple-keyboard{font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;overflow:hidden;touch-action:manipulation}.simple-keyboard .hg-row{display:-webkit-flex;display:flex}.simple-keyboard .hg-row:not(:last-child){margin-bottom:5px}.simple-keyboard .hg-row .hg-button-container,.simple-keyboard .hg-row .hg-button:not(:last-child){margin-right:5px}.simple-keyboard .hg-row>div:last-child{margin-right:0}.simple-keyboard .hg-row .hg-button-container{display:-webkit-flex;display:flex}.simple-keyboard .hg-button{display:inline-block;-webkit-flex-grow:1;flex-grow:1;cursor:pointer}.simple-keyboard .hg-button span{pointer-events:none}.simple-keyboard.hg-theme-default{background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.simple-keyboard.hg-theme-default .hg-button{box-shadow:0 0 3px -1px rgba(0,0,0,.3);height:40px;border-radius:5px;box-sizing:border-box;padding:5px;background:#fff;border-bottom:1px solid #b5b5b5;cursor:pointer;display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active{background:#e4e4e4}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.simple-keyboard.hg-theme-default .hg-button.hg-button-com{max-width:85px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton{background:rgba(5,25,70,.53);color:#fff}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}
|
||||
*/body,html{margin:0;padding:0}.simple-keyboard{font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;width:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;box-sizing:border-box;overflow:hidden;touch-action:manipulation}.simple-keyboard .hg-row{display:flex}.simple-keyboard .hg-row:not(:last-child){margin-bottom:5px}.simple-keyboard .hg-row .hg-button-container,.simple-keyboard .hg-row .hg-button:not(:last-child){margin-right:5px}.simple-keyboard .hg-row>div:last-child{margin-right:0}.simple-keyboard .hg-row .hg-button-container{display:flex}.simple-keyboard .hg-button{display:inline-block;flex-grow:1;cursor:pointer}.simple-keyboard .hg-button span{pointer-events:none}.simple-keyboard.hg-theme-default{background-color:rgba(0,0,0,.1);padding:5px;border-radius:5px}.simple-keyboard.hg-theme-default .hg-button{box-shadow:0 0 3px -1px rgba(0,0,0,.3);height:40px;border-radius:5px;box-sizing:border-box;padding:5px;background:#fff;border-bottom:1px solid #b5b5b5;cursor:pointer;display:flex;align-items:center;justify-content:center}.simple-keyboard button.hg-button{border-width:0;outline:0;font-size:inherit}.simple-keyboard.hg-theme-default:not(.hg-touch-events) .hg-button:active{background:#e4e4e4}.simple-keyboard.hg-theme-default.hg-layout-numeric .hg-button{width:33.3%;height:60px;align-items:center;display:flex;justify-content:center}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadadd,.simple-keyboard.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.simple-keyboard.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.simple-keyboard.hg-theme-default .hg-button.hg-button-com{max-width:85px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.simple-keyboard.hg-theme-default .hg-button.hg-selectedButton{background:rgba(5,25,70,.53);color:#fff}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"]{max-width:82px}.simple-keyboard.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"]{max-width:60px}
|
||||
12
build/index.d.ts
vendored
12
build/index.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
declare module 'simple-keyboard' {
|
||||
interface KeyboardLayoutObject {
|
||||
default: string[];
|
||||
shift?: string[];
|
||||
shift?: any;
|
||||
[key: string]: string[];
|
||||
}
|
||||
|
||||
@@ -123,6 +123,11 @@ declare module 'simple-keyboard' {
|
||||
*/
|
||||
useMouseEvents?: boolean;
|
||||
|
||||
/**
|
||||
* Disable button hold action.
|
||||
*/
|
||||
disableButtonHold?: boolean;
|
||||
|
||||
/**
|
||||
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
|
||||
*/
|
||||
@@ -220,6 +225,11 @@ declare module 'simple-keyboard' {
|
||||
* @param {string} button The button layout name to select
|
||||
*/
|
||||
getButtonElement(button: string): HTMLElement | HTMLElement[];
|
||||
|
||||
/**
|
||||
* Clears keyboard listeners and DOM elements.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export default Keyboard;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.21.0 (Non-minified build)
|
||||
* simple-keyboard v2.23.0 (Non-minified build)
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
@@ -823,6 +823,8 @@
|
||||
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
|
||||
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
|
||||
* @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.
|
||||
* @property {function} destroy Clears keyboard listeners and DOM elements.
|
||||
* @property {boolean} disableButtonHold Disable button hold action.
|
||||
*/ this.options = options;
|
||||
this.options.layoutName = this.options.layoutName || "default";
|
||||
this.options.theme = this.options.theme || "hg-theme-default";
|
||||
@@ -958,15 +960,17 @@
|
||||
/**
|
||||
* @type {object} Time to wait until a key hold is detected
|
||||
*/ }
|
||||
this.holdTimeout = setTimeout(function() {
|
||||
if (_this2.isMouseHold && (!button.includes("{") && !button.includes("}") || button === "{delete}" || button === "{backspace}" || button === "{bksp}" || button === "{space}" || button === "{tab}")) {
|
||||
if (_this2.options.debug) {
|
||||
console.log("Button held:", button);
|
||||
if (!this.options.disableButtonHold) {
|
||||
this.holdTimeout = setTimeout(function() {
|
||||
if (_this2.isMouseHold && (!button.includes("{") && !button.includes("}") || button === "{delete}" || button === "{backspace}" || button === "{bksp}" || button === "{space}" || button === "{tab}")) {
|
||||
if (_this2.options.debug) {
|
||||
console.log("Button held:", button);
|
||||
}
|
||||
_this2.handleButtonHold(button, e);
|
||||
}
|
||||
_this2.handleButtonHold(button, e);
|
||||
}
|
||||
clearTimeout(_this2.holdTimeout);
|
||||
}, 500);
|
||||
clearTimeout(_this2.holdTimeout);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handles button mouseup
|
||||
@@ -1294,6 +1298,20 @@
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Destroy keyboard listeners and DOM elements
|
||||
*/ }, {
|
||||
key: "destroy",
|
||||
value: function destroy() {
|
||||
/**
|
||||
* Remove listeners
|
||||
*/ document.removeEventListener("keyup", this.caretEventHandler);
|
||||
document.removeEventListener("mouseup", this.caretEventHandler);
|
||||
document.removeEventListener("touchend", this.caretEventHandler);
|
||||
/**
|
||||
* Clear DOM
|
||||
*/ this.clear();
|
||||
}
|
||||
/**
|
||||
* Process buttonTheme option
|
||||
*/ }, {
|
||||
key: "getButtonTheme",
|
||||
|
||||
9171
package-lock.json
generated
9171
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
57
package.json
57
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "2.21.0",
|
||||
"version": "2.23.0",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -40,65 +40,66 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.4.4",
|
||||
"@babel/core": "7.4.5",
|
||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
||||
"@babel/preset-env": "^7.4.4",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@svgr/webpack": "4.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "1.7.0",
|
||||
"@typescript-eslint/parser": "1.7.0",
|
||||
"@babel/runtime": "^7.4.4",
|
||||
"@svgr/webpack": "4.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "1.9.0",
|
||||
"@typescript-eslint/parser": "1.9.0",
|
||||
"babel-eslint": "10.0.1",
|
||||
"babel-jest": "24.7.1",
|
||||
"babel-loader": "8.0.5",
|
||||
"babel-jest": "24.8.0",
|
||||
"babel-loader": "8.0.6",
|
||||
"babel-plugin-named-asset-import": "^0.3.2",
|
||||
"babel-preset-react-app": "^8.0.0",
|
||||
"babel-preset-react-app": "^9.0.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.2.0",
|
||||
"copy-webpack-plugin": "^5.0.2",
|
||||
"copy-webpack-plugin": "^5.0.3",
|
||||
"css-loader": "2.1.1",
|
||||
"dotenv": "7.0.0",
|
||||
"dotenv": "8.0.0",
|
||||
"dotenv-expand": "5.1.0",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-react-app": "^4.0.0",
|
||||
"eslint-config-react-app": "^4.0.1",
|
||||
"eslint-loader": "2.1.2",
|
||||
"eslint-plugin-flowtype": "3.6.1",
|
||||
"eslint-plugin-import": "2.17.2",
|
||||
"eslint-plugin-flowtype": "3.9.1",
|
||||
"eslint-plugin-import": "2.17.3",
|
||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"eslint-plugin-react": "7.13.0",
|
||||
"eslint-plugin-react-hooks": "^1.5.0",
|
||||
"file-loader": "3.0.1",
|
||||
"fs-extra": "7.0.1",
|
||||
"fs-extra": "8.0.1",
|
||||
"html-webpack-plugin": "4.0.0-beta.5",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"is-wsl": "^2.0.0",
|
||||
"jest": "24.7.1",
|
||||
"jest": "24.8.0",
|
||||
"jest-environment-jsdom-fourteen": "0.1.0",
|
||||
"jest-resolve": "24.7.1",
|
||||
"jest-watch-typeahead": "0.3.0",
|
||||
"mini-css-extract-plugin": "0.6.0",
|
||||
"jest-resolve": "24.8.0",
|
||||
"jest-watch-typeahead": "0.3.1",
|
||||
"mini-css-extract-plugin": "0.7.0",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.1",
|
||||
"pnp-webpack-plugin": "1.4.3",
|
||||
"postcss-flexbugs-fixes": "4.1.0",
|
||||
"postcss-loader": "3.0.0",
|
||||
"postcss-normalize": "7.0.1",
|
||||
"postcss-normalize": "7.0.0",
|
||||
"postcss-preset-env": "6.6.0",
|
||||
"postcss-safe-parser": "4.0.1",
|
||||
"prettier": "^1.17.0",
|
||||
"prettier-webpack-plugin": "^1.2.0",
|
||||
"react": "^16.8.6",
|
||||
"react-app-polyfill": "^1.0.0",
|
||||
"react-dev-utils": "^9.0.0",
|
||||
"react-app-polyfill": "^1.0.1",
|
||||
"react-dev-utils": "^9.0.1",
|
||||
"react-dom": "^16.8.6",
|
||||
"resolve": "1.10.1",
|
||||
"resolve": "1.11.1",
|
||||
"sass-loader": "7.1.0",
|
||||
"semver": "6.0.0",
|
||||
"semver": "6.1.1",
|
||||
"style-loader": "0.23.1",
|
||||
"terser-webpack-plugin": "1.2.3",
|
||||
"terser-webpack-plugin": "1.3.0",
|
||||
"uglifyjs-webpack-plugin": "^2.1.2",
|
||||
"url-loader": "1.1.2",
|
||||
"webpack": "4.30.0",
|
||||
"webpack-dev-server": "3.3.1",
|
||||
"webpack": "4.33.0",
|
||||
"webpack-dev-server": "3.5.1",
|
||||
"webpack-manifest-plugin": "2.0.4",
|
||||
"workbox-webpack-plugin": "4.3.0"
|
||||
"workbox-webpack-plugin": "4.3.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app",
|
||||
|
||||
12
src/lib/@types/index.d.ts
vendored
12
src/lib/@types/index.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
declare module 'simple-keyboard' {
|
||||
interface KeyboardLayoutObject {
|
||||
default: string[];
|
||||
shift?: string[];
|
||||
shift?: any;
|
||||
[key: string]: string[];
|
||||
}
|
||||
|
||||
@@ -123,6 +123,11 @@ declare module 'simple-keyboard' {
|
||||
*/
|
||||
useMouseEvents?: boolean;
|
||||
|
||||
/**
|
||||
* Disable button hold action.
|
||||
*/
|
||||
disableButtonHold?: boolean;
|
||||
|
||||
/**
|
||||
* Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
|
||||
*/
|
||||
@@ -220,6 +225,11 @@ declare module 'simple-keyboard' {
|
||||
* @param {string} button The button layout name to select
|
||||
*/
|
||||
getButtonElement(button: string): HTMLElement | HTMLElement[];
|
||||
|
||||
/**
|
||||
* Clears keyboard listeners and DOM elements.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export default Keyboard;
|
||||
|
||||
@@ -64,6 +64,8 @@ class SimpleKeyboard {
|
||||
* @property {boolean} useTouchEvents Instructs simple-keyboard to use touch events instead of click events.
|
||||
* @property {boolean} autoUseTouchEvents Enable useTouchEvents automatically when touch device is detected.
|
||||
* @property {boolean} useMouseEvents Opt out of PointerEvents handling, falling back to the prior mouse event logic.
|
||||
* @property {function} destroy Clears keyboard listeners and DOM elements.
|
||||
* @property {boolean} disableButtonHold Disable button hold action.
|
||||
*/
|
||||
this.options = options;
|
||||
this.options.layoutName = this.options.layoutName || "default";
|
||||
@@ -244,22 +246,24 @@ class SimpleKeyboard {
|
||||
/**
|
||||
* @type {object} Time to wait until a key hold is detected
|
||||
*/
|
||||
this.holdTimeout = setTimeout(() => {
|
||||
if (
|
||||
this.isMouseHold &&
|
||||
((!button.includes("{") && !button.includes("}")) ||
|
||||
button === "{delete}" ||
|
||||
button === "{backspace}" ||
|
||||
button === "{bksp}" ||
|
||||
button === "{space}" ||
|
||||
button === "{tab}")
|
||||
) {
|
||||
if (this.options.debug) console.log("Button held:", button);
|
||||
if (!this.options.disableButtonHold) {
|
||||
this.holdTimeout = setTimeout(() => {
|
||||
if (
|
||||
this.isMouseHold &&
|
||||
((!button.includes("{") && !button.includes("}")) ||
|
||||
button === "{delete}" ||
|
||||
button === "{backspace}" ||
|
||||
button === "{bksp}" ||
|
||||
button === "{space}" ||
|
||||
button === "{tab}")
|
||||
) {
|
||||
if (this.options.debug) console.log("Button held:", button);
|
||||
|
||||
this.handleButtonHold(button, e);
|
||||
}
|
||||
clearTimeout(this.holdTimeout);
|
||||
}, 500);
|
||||
this.handleButtonHold(button, e);
|
||||
}
|
||||
clearTimeout(this.holdTimeout);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -646,6 +650,23 @@ class SimpleKeyboard {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy keyboard listeners and DOM elements
|
||||
*/
|
||||
destroy() {
|
||||
/**
|
||||
* Remove listeners
|
||||
*/
|
||||
document.removeEventListener("keyup", this.caretEventHandler);
|
||||
document.removeEventListener("mouseup", this.caretEventHandler);
|
||||
document.removeEventListener("touchend", this.caretEventHandler);
|
||||
|
||||
/**
|
||||
* Clear DOM
|
||||
*/
|
||||
this.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process buttonTheme option
|
||||
*/
|
||||
|
||||
@@ -1222,4 +1222,24 @@ it('Keyboard inputName change will trigget caretPosition reset', () => {
|
||||
keyboard.getButtonElement("b").onpointerdown();
|
||||
|
||||
expect(keyboard.caretPosition).toBe(null);
|
||||
});
|
||||
|
||||
it('Keyboard destroy will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
|
||||
keyboard.destroy();
|
||||
|
||||
expect(keyboard.keyboardDOM.innerHTML).toBeFalsy();
|
||||
});
|
||||
|
||||
it('Keyboard disableButtonHold will work', () => {
|
||||
testUtil.setDOM();
|
||||
|
||||
let keyboard = new Keyboard({
|
||||
disableButtonHold: true
|
||||
});
|
||||
|
||||
expect(keyboard.options.disableButtonHold).toBe(true);
|
||||
});
|
||||
Reference in New Issue
Block a user