mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-02-15 00:07:43 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f83884af5c | ||
|
|
be25e26c46 | ||
|
|
3b93f37cb2 | ||
|
|
822e7a97b7 | ||
|
|
bc420bb60c | ||
|
|
1aedf9c487 | ||
|
|
0052efa582 | ||
|
|
316319a311 | ||
|
|
02bc34e3b7 | ||
|
|
d38433be1c | ||
|
|
366f4cd98e | ||
|
|
ee3d6a18f2 | ||
|
|
e6d6c78389 | ||
|
|
ba09ac7952 | ||
|
|
3ee9873d77 | ||
|
|
347480735c | ||
|
|
3086a45295 | ||
|
|
d33d557f08 | ||
|
|
f8fb18e244 | ||
|
|
2d8799367a |
8
.github/pull_request_template.md
vendored
Normal file
8
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
## Description
|
||||
|
||||
A few sentences describing the overall goals of the pull request's commits.
|
||||
|
||||
## Checks
|
||||
|
||||
- [ ] Tests ( `npm run test -- --coverage` ) Coverage at `./coverage/lcov-report/index.html` should be 100%
|
||||
- [ ] Documentation ( `npm run docs` ) Coverage at `./docs/source.html` should be 100%
|
||||
@@ -6,6 +6,7 @@ install:
|
||||
- npm install
|
||||
script:
|
||||
- npm run test -- --coverage
|
||||
- npm run demo
|
||||
- codecov
|
||||
after_success:
|
||||
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v2.8.0
|
||||
* simple-keyboard v2.10.0
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -326,10 +326,13 @@ module.exports = {
|
||||
configFile: false,
|
||||
compact: false,
|
||||
presets: [
|
||||
[
|
||||
require.resolve('babel-preset-react-app/dependencies'),
|
||||
{ helpers: true },
|
||||
],
|
||||
"@babel/preset-env",
|
||||
"@babel/preset-react"
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
"@babel/plugin-proposal-class-properties"
|
||||
]
|
||||
],
|
||||
cacheDirectory: true,
|
||||
// Save disk space when time isn't as important
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1345,7 +1345,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber121">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber123">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1388,7 +1388,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber535">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber541">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1433,7 +1433,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber613">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber619">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1477,7 +1477,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber623">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber629">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1521,7 +1521,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber272">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber274">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1564,7 +1564,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber233">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber235">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1607,7 +1607,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber768">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber783">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1651,7 +1651,7 @@ As keys are pressed, text will be added/removed at that position within the inpu
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber110">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber112">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1731,7 +1731,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber222">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber224">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1818,7 +1818,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber116">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber118">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1861,7 +1861,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber69">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber71">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1904,7 +1904,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber150">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber152">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -1948,7 +1948,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber61">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber62">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2065,6 +2065,13 @@ keyboard.clearInput();</code></pre>
|
||||
<td data-ice="description"><p>Enable highlighting of keys pressed on physical keyboard.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr data-ice="property" data-depth="0">
|
||||
<td data-ice="name" class="code" data-depth="0">preventMouseDownDefault</td>
|
||||
<td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span></td>
|
||||
<td data-ice="appendix"></td>
|
||||
<td data-ice="description"><p>Calling preventDefault for the mousedown events keeps the focus on the input.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr data-ice="property" data-depth="0">
|
||||
<td data-ice="name" class="code" data-depth="0">physicalKeyboardHighlightTextColor</td>
|
||||
<td data-ice="type" class="code"><span><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span></td>
|
||||
@@ -2148,7 +2155,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber145">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber147">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2192,7 +2199,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber579">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber585">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2236,7 +2243,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber350">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber352">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2327,7 +2334,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber386">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber388">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2407,7 +2414,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber519">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber521">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2467,7 +2474,7 @@ keyboard.clearInput();</code></pre>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber360">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber362">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2512,7 +2519,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber295">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber297">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2573,7 +2580,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber370">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber372">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2646,7 +2653,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber488">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber490">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2719,7 +2726,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber310">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber312">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2792,7 +2799,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber158">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber160">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2865,7 +2872,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber265">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber267">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2925,7 +2932,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber218">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber220">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -2991,7 +2998,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber255">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber257">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3035,7 +3042,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber506">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber508">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3079,7 +3086,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber589">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber595">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3123,7 +3130,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber546">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber552">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3167,7 +3174,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber571">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber577">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3211,7 +3218,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber563">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber569">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3255,7 +3262,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber436">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber438">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3335,7 +3342,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber630">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber636">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3379,7 +3386,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber342">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber344">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3440,7 +3447,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber327">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber329">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
@@ -3508,7 +3515,7 @@ Used interally between re-renders.</p>
|
||||
<span class="right-info">
|
||||
|
||||
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber285">source</a></span></span>
|
||||
<span data-ice="source"><span><a href="file/src/lib/components/Keyboard.js.html#lineNumber287">source</a></span></span>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
|
||||
@@ -92,8 +92,9 @@ class SimpleKeyboard {
|
||||
* @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
|
||||
* @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.
|
||||
* @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.
|
||||
* @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||
* @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.
|
||||
* @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.
|
||||
* @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.
|
||||
* @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).
|
||||
* @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.
|
||||
* @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
|
||||
@@ -104,6 +105,7 @@ class SimpleKeyboard {
|
||||
this.options.layoutName = this.options.layoutName || "default";
|
||||
this.options.theme = this.options.theme || "hg-theme-default";
|
||||
this.options.inputName = this.options.inputName || "default";
|
||||
this.options.preventMouseDownDefault = this.options.preventMouseDownDefault === false ? false : true;
|
||||
|
||||
/**
|
||||
* @type {object} Classes identifying loaded plugins
|
||||
@@ -336,7 +338,7 @@ class SimpleKeyboard {
|
||||
*/
|
||||
clearInput(inputName){
|
||||
inputName = inputName || this.options.inputName;
|
||||
this.input[this.options.inputName] = '';
|
||||
this.input[inputName] = '';
|
||||
|
||||
/**
|
||||
* Enforce syncInstanceInputs, if set
|
||||
@@ -561,6 +563,10 @@ class SimpleKeyboard {
|
||||
caretEventHandler(event){
|
||||
let targetTagName;
|
||||
|
||||
if(this.isMouseHold){
|
||||
this.isMouseHold = false;
|
||||
}
|
||||
|
||||
if(event.target.tagName){
|
||||
targetTagName = event.target.tagName.toLowerCase();
|
||||
}
|
||||
@@ -677,6 +683,7 @@ class SimpleKeyboard {
|
||||
|
||||
let layoutClass = this.options.layout ? "hg-layout-custom" : `hg-layout-${this.options.layoutName}`;
|
||||
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
||||
let useTouchEvents = this.options.useTouchEvents || false
|
||||
|
||||
/**
|
||||
* Account for buttonTheme, if set
|
||||
@@ -742,12 +749,25 @@ class SimpleKeyboard {
|
||||
*/
|
||||
var buttonDOM = document.createElement('div');
|
||||
buttonDOM.className += `hg-button ${fctBtnClass}${buttonThemeClass ? " "+buttonThemeClass : ""}`;
|
||||
buttonDOM.onclick = () => {
|
||||
this.isMouseHold = false;
|
||||
this.handleButtonClicked(button);
|
||||
|
||||
if (useTouchEvents) {
|
||||
buttonDOM.ontouchstart = (e) => {
|
||||
this.handleButtonClicked(button);
|
||||
this.handleButtonMouseDown(button, e);
|
||||
}
|
||||
buttonDOM.ontouchend = e => this.handleButtonMouseUp();
|
||||
buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();
|
||||
} else {
|
||||
buttonDOM.onclick = () => {
|
||||
this.isMouseHold = false;
|
||||
this.handleButtonClicked(button);
|
||||
}
|
||||
buttonDOM.onmousedown = (e) => {
|
||||
if (this.options.preventMouseDownDefault) e.preventDefault();
|
||||
this.handleButtonMouseDown(button, e);
|
||||
}
|
||||
}
|
||||
buttonDOM.onmousedown = (e) => this.handleButtonMouseDown(button, e);
|
||||
|
||||
|
||||
/**
|
||||
* Adding identifier
|
||||
*/
|
||||
@@ -798,17 +818,19 @@ class SimpleKeyboard {
|
||||
*/
|
||||
this.onRender();
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
|
||||
if(!this.initialized){
|
||||
/**
|
||||
* Ensures that onInit is only called once per instantiation
|
||||
*/
|
||||
this.initialized = true;
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
if (!useTouchEvents) {
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling onInit
|
||||
*/
|
||||
|
||||
236
docs/index.json
236
docs/index.json
File diff suppressed because one or more lines are too long
@@ -60,7 +60,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">8/8</span></td>
|
||||
<td style="display: none;" data-ice="size">1919 byte</td>
|
||||
<td style="display: none;" data-ice="lines">84</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-02 22:34:11 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/demo/index.js.html">src/demo/index.js</a></span></td>
|
||||
@@ -68,15 +68,15 @@
|
||||
<td class="coverage"><span data-ice="coverage">-</span></td>
|
||||
<td style="display: none;" data-ice="size">70 byte</td>
|
||||
<td style="display: none;" data-ice="lines">5</td>
|
||||
<td style="display: none;" data-ice="updated">2018-09-02 03:31:31 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/components/Keyboard.js.html">src/lib/components/Keyboard.js</a></span></td>
|
||||
<td data-ice="identifier" class="identifiers"><span><a href="class/src/lib/components/Keyboard.js~SimpleKeyboard.html">SimpleKeyboard</a></span></td>
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">41/41</span></td>
|
||||
<td style="display: none;" data-ice="size">24942 byte</td>
|
||||
<td style="display: none;" data-ice="lines">778</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-06 15:50:43 (UTC)</td>
|
||||
<td style="display: none;" data-ice="size">25831 byte</td>
|
||||
<td style="display: none;" data-ice="lines">800</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:59:59 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/index.js.html">src/lib/index.js</a></span></td>
|
||||
@@ -84,7 +84,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">-</span></td>
|
||||
<td style="display: none;" data-ice="size">85 byte</td>
|
||||
<td style="display: none;" data-ice="lines">2</td>
|
||||
<td style="display: none;" data-ice="updated">2018-06-06 23:02:53 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/services/KeyboardLayout.js.html">src/lib/services/KeyboardLayout.js</a></span></td>
|
||||
@@ -92,7 +92,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">2/2</span></td>
|
||||
<td style="display: none;" data-ice="size">746 byte</td>
|
||||
<td style="display: none;" data-ice="lines">28</td>
|
||||
<td style="display: none;" data-ice="updated">2018-10-03 02:14:58 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/services/PhysicalKeyboard.js.html">src/lib/services/PhysicalKeyboard.js</a></span></td>
|
||||
@@ -100,7 +100,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">5/5</span></td>
|
||||
<td style="display: none;" data-ice="size">2908 byte</td>
|
||||
<td style="display: none;" data-ice="lines">96</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-06 15:54:53 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/services/Utilities.js.html">src/lib/services/Utilities.js</a></span></td>
|
||||
@@ -108,7 +108,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">15/15</span></td>
|
||||
<td style="display: none;" data-ice="size">11188 byte</td>
|
||||
<td style="display: none;" data-ice="lines">360</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-02 22:28:58 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
<tr data-ice="file">
|
||||
<td data-ice="filePath"><span><a href="file/src/lib/tests/TestUtility.js.html">src/lib/tests/TestUtility.js</a></span></td>
|
||||
@@ -116,7 +116,7 @@
|
||||
<td class="coverage"><span data-ice="coverage">100 %</span><span data-ice="coverageCount" class="coverage-count">6/6</span></td>
|
||||
<td style="display: none;" data-ice="size">2830 byte</td>
|
||||
<td style="display: none;" data-ice="lines">106</td>
|
||||
<td style="display: none;" data-ice="updated">2018-10-04 22:12:09 (UTC)</td>
|
||||
<td style="display: none;" data-ice="updated">2018-11-01 00:54:03 (UTC)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
1008
package-lock.json
generated
1008
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "2.8.0",
|
||||
"version": "2.10.0",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
@@ -39,7 +39,10 @@
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.1.0",
|
||||
"@svgr/webpack": "2.4.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.6",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@svgr/webpack": "4.0.3",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"babel-eslint": "9.0.0",
|
||||
"babel-jest": "23.6.0",
|
||||
@@ -49,27 +52,31 @@
|
||||
"bfj": "6.1.1",
|
||||
"case-sensitive-paths-webpack-plugin": "2.1.2",
|
||||
"chalk": "2.4.1",
|
||||
"css-loader": "1.0.0",
|
||||
"css-loader": "1.0.1",
|
||||
"dotenv": "6.0.0",
|
||||
"dotenv-expand": "4.2.0",
|
||||
"eslint": "5.6.0",
|
||||
"esdoc": "^1.1.0",
|
||||
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
|
||||
"esdoc-standard-plugin": "^1.0.0",
|
||||
"eslint": "5.9.0",
|
||||
"eslint-config-react-app": "^3.0.5",
|
||||
"eslint-loader": "2.1.1",
|
||||
"eslint-plugin-flowtype": "2.50.1",
|
||||
"eslint-plugin-flowtype": "2.50.3",
|
||||
"eslint-plugin-import": "2.14.0",
|
||||
"eslint-plugin-jsx-a11y": "6.1.2",
|
||||
"eslint-plugin-react": "7.11.1",
|
||||
"file-loader": "2.0.0",
|
||||
"fork-ts-checker-webpack-plugin-alt": "0.4.14",
|
||||
"fs-extra": "7.0.0",
|
||||
"html-webpack-plugin": "4.0.0-alpha.2",
|
||||
"har-validator": "^5.1.3",
|
||||
"html-webpack-plugin": "4.0.0-beta.4",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"jest": "23.6.0",
|
||||
"jest-pnp-resolver": "1.0.1",
|
||||
"jest-resolve": "23.6.0",
|
||||
"mini-css-extract-plugin": "0.4.3",
|
||||
"mini-css-extract-plugin": "0.4.4",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.1",
|
||||
"pnp-webpack-plugin": "1.1.0",
|
||||
"pnp-webpack-plugin": "1.2.0",
|
||||
"postcss-flexbugs-fixes": "4.1.0",
|
||||
"postcss-loader": "3.0.0",
|
||||
"postcss-preset-env": "6.0.6",
|
||||
@@ -83,13 +90,10 @@
|
||||
"style-loader": "0.23.0",
|
||||
"terser-webpack-plugin": "1.1.0",
|
||||
"url-loader": "1.1.1",
|
||||
"webpack": "4.19.1",
|
||||
"webpack-dev-server": "3.1.9",
|
||||
"webpack": "4.25.1",
|
||||
"webpack-dev-server": "3.1.10",
|
||||
"webpack-manifest-plugin": "2.0.4",
|
||||
"workbox-webpack-plugin": "3.6.3",
|
||||
"esdoc": "^1.1.0",
|
||||
"esdoc-ecmascript-proposal-plugin": "^1.0.0",
|
||||
"esdoc-standard-plugin": "^1.0.0"
|
||||
"workbox-webpack-plugin": "3.6.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
@@ -144,7 +148,13 @@
|
||||
},
|
||||
"babel": {
|
||||
"presets": [
|
||||
"react-app"
|
||||
"@babel/preset-env",
|
||||
"@babel/preset-react"
|
||||
],
|
||||
"plugins": [
|
||||
[
|
||||
"@babel/plugin-proposal-class-properties"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ class SimpleKeyboard {
|
||||
* @property {object} maxLength Restrains simple-keyboard’s individual inputs to a certain length. This should be used in addition to the input element’s maxlengthattribute.
|
||||
* @property {boolean} syncInstanceInputs When set to true, this option synchronizes the internal input of every simple-keyboard instance.
|
||||
* @property {boolean} physicalKeyboardHighlight Enable highlighting of keys pressed on physical keyboard.
|
||||
* @property {boolean} preventMouseDownDefault Calling preventDefault for the mousedown events keeps the focus on the input.
|
||||
* @property {string} physicalKeyboardHighlightTextColor Define the text color that the physical keyboard highlighted key should have.
|
||||
* @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.
|
||||
* @property {string} physicalKeyboardHighlightBgColor Define the background color that the physical keyboard highlighted key should have.
|
||||
* @property {function(button: string):string} onKeyPress Executes the callback function on key press. Returns button layout name (i.e.: “{shift}”).
|
||||
* @property {function(input: string):string} onChange Executes the callback function on input change. Returns the current input’s string.
|
||||
* @property {function} onRender Executes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
|
||||
@@ -62,6 +63,7 @@ class SimpleKeyboard {
|
||||
this.options.layoutName = this.options.layoutName || "default";
|
||||
this.options.theme = this.options.theme || "hg-theme-default";
|
||||
this.options.inputName = this.options.inputName || "default";
|
||||
this.options.preventMouseDownDefault = this.options.preventMouseDownDefault === false ? false : true;
|
||||
|
||||
/**
|
||||
* @type {object} Classes identifying loaded plugins
|
||||
@@ -294,7 +296,7 @@ class SimpleKeyboard {
|
||||
*/
|
||||
clearInput(inputName){
|
||||
inputName = inputName || this.options.inputName;
|
||||
this.input[this.options.inputName] = '';
|
||||
this.input[inputName] = '';
|
||||
|
||||
/**
|
||||
* Enforce syncInstanceInputs, if set
|
||||
@@ -519,6 +521,10 @@ class SimpleKeyboard {
|
||||
caretEventHandler(event){
|
||||
let targetTagName;
|
||||
|
||||
if(this.isMouseHold){
|
||||
this.isMouseHold = false;
|
||||
}
|
||||
|
||||
if(event.target.tagName){
|
||||
targetTagName = event.target.tagName.toLowerCase();
|
||||
}
|
||||
@@ -635,6 +641,7 @@ class SimpleKeyboard {
|
||||
|
||||
let layoutClass = this.options.layout ? "hg-layout-custom" : `hg-layout-${this.options.layoutName}`;
|
||||
let layout = this.options.layout || KeyboardLayout.getDefaultLayout();
|
||||
let useTouchEvents = this.options.useTouchEvents || false
|
||||
|
||||
/**
|
||||
* Account for buttonTheme, if set
|
||||
@@ -700,12 +707,25 @@ class SimpleKeyboard {
|
||||
*/
|
||||
var buttonDOM = document.createElement('div');
|
||||
buttonDOM.className += `hg-button ${fctBtnClass}${buttonThemeClass ? " "+buttonThemeClass : ""}`;
|
||||
buttonDOM.onclick = () => {
|
||||
this.isMouseHold = false;
|
||||
this.handleButtonClicked(button);
|
||||
|
||||
if (useTouchEvents) {
|
||||
buttonDOM.ontouchstart = (e) => {
|
||||
this.handleButtonClicked(button);
|
||||
this.handleButtonMouseDown(button, e);
|
||||
}
|
||||
buttonDOM.ontouchend = e => this.handleButtonMouseUp();
|
||||
buttonDOM.ontouchcancel = e => this.handleButtonMouseUp();
|
||||
} else {
|
||||
buttonDOM.onclick = () => {
|
||||
this.isMouseHold = false;
|
||||
this.handleButtonClicked(button);
|
||||
}
|
||||
buttonDOM.onmousedown = (e) => {
|
||||
if (this.options.preventMouseDownDefault) e.preventDefault();
|
||||
this.handleButtonMouseDown(button, e);
|
||||
}
|
||||
}
|
||||
buttonDOM.onmousedown = (e) => this.handleButtonMouseDown(button, e);
|
||||
|
||||
|
||||
/**
|
||||
* Adding identifier
|
||||
*/
|
||||
@@ -756,17 +776,19 @@ class SimpleKeyboard {
|
||||
*/
|
||||
this.onRender();
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
|
||||
if(!this.initialized){
|
||||
/**
|
||||
* Ensures that onInit is only called once per instantiation
|
||||
*/
|
||||
this.initialized = true;
|
||||
|
||||
/**
|
||||
* Handling mouseup
|
||||
*/
|
||||
if (!useTouchEvents) {
|
||||
document.onmouseup = () => this.handleButtonMouseUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calling onInit
|
||||
*/
|
||||
|
||||
@@ -45,6 +45,32 @@ it('Keyboard will run with debug option set', () => {
|
||||
expect(keyboard.options.debug).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Keyboard will use touch events', () => {
|
||||
let touched = false
|
||||
|
||||
testUtil.clear()
|
||||
|
||||
document.body.innerHTML = `
|
||||
<div id="keyboard"></div>
|
||||
`;
|
||||
|
||||
const keyboard = new Keyboard('#keyboard', {
|
||||
useTouchEvents: true,
|
||||
onChange: () => touched = true,
|
||||
layout: {
|
||||
default: ["q"]
|
||||
}
|
||||
});
|
||||
|
||||
keyboard.getButtonElement("q").ontouchstart();
|
||||
keyboard.getButtonElement("q").ontouchend();
|
||||
keyboard.getButtonElement("q").ontouchcancel();
|
||||
|
||||
expect(keyboard.options.useTouchEvents).toBeTruthy();
|
||||
expect(touched).toBeTruthy();
|
||||
expect(keyboard.getInput()).toBe('q');
|
||||
})
|
||||
|
||||
it('Keyboard standard buttons will work', () => {
|
||||
testUtil.setDOM();
|
||||
let keyboard = new Keyboard({
|
||||
@@ -575,6 +601,8 @@ it('Keyboard caretEventHandler ignore positioning if input, textarea is blur', (
|
||||
|
||||
let keyboard = new Keyboard();
|
||||
|
||||
keyboard.isMouseHold = true;
|
||||
|
||||
keyboard.caretEventHandler({
|
||||
charCode: 0,
|
||||
code: "KeyF",
|
||||
@@ -835,7 +863,9 @@ it('Keyboard handleButtonMouseDown will work', () => {
|
||||
target: keyboard.getButtonElement("q")
|
||||
});
|
||||
|
||||
keyboard.getButtonElement("q").onmousedown();
|
||||
var clickEvent = document.createEvent('MouseEvents');
|
||||
clickEvent.initEvent('mousedown', true, true);
|
||||
keyboard.getButtonElement("q").dispatchEvent(clickEvent);
|
||||
document.onmouseup();
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user