mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-02-03 00:06:50 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
de2100cb7b | ||
|
|
04a3c186f0 | ||
|
|
5fa612a923 | ||
|
|
9a34b6eb37 | ||
|
|
66fa632ca4 | ||
|
|
51d6d66fc6 | ||
|
|
84d2c45887 | ||
|
|
966bfd47db | ||
|
|
02d88bae10 | ||
|
|
6802c1f9dc |
@@ -1,6 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '11.2'
|
||||
- node
|
||||
install:
|
||||
- npm install -g codecov
|
||||
- npm install
|
||||
|
||||
6375
package-lock.json
generated
6375
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "2.22.0",
|
||||
"version": "2.23.0",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
@@ -80,7 +80,7 @@
|
||||
"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",
|
||||
@@ -89,15 +89,15 @@
|
||||
"react-app-polyfill": "^1.0.1",
|
||||
"react-dev-utils": "^9.0.1",
|
||||
"react-dom": "^16.8.6",
|
||||
"resolve": "1.11.0",
|
||||
"resolve": "1.11.1",
|
||||
"sass-loader": "7.1.0",
|
||||
"semver": "6.1.1",
|
||||
"style-loader": "0.23.1",
|
||||
"terser-webpack-plugin": "1.3.0",
|
||||
"uglifyjs-webpack-plugin": "^2.1.2",
|
||||
"url-loader": "1.1.2",
|
||||
"webpack": "4.32.2",
|
||||
"webpack-dev-server": "3.5.0",
|
||||
"webpack": "4.33.0",
|
||||
"webpack-dev-server": "3.5.1",
|
||||
"webpack-manifest-plugin": "2.0.4",
|
||||
"workbox-webpack-plugin": "4.3.1"
|
||||
},
|
||||
|
||||
5
src/lib/@types/index.d.ts
vendored
5
src/lib/@types/index.d.ts
vendored
@@ -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}").
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,7 @@ class SimpleKeyboard {
|
||||
* @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";
|
||||
@@ -245,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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1232,4 +1232,14 @@ it('Keyboard destroy will work', () => {
|
||||
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