Francisco Hodge 2e3ca5716b Docs update
2018-10-24 18:18:24 -04:00

146 lines
5.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<base data-ice="baseUrl" href="../../../">
<title data-ice="title">src/demo/App.js | simple-keyboard</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
<script src="script/prettify/prettify.js"></script>
<script src="script/manual.js"></script>
<meta name="description" content="On-screen Javascript Virtual Keyboard"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="simple-keyboard"><meta property="twitter:description" content="On-screen Javascript Virtual Keyboard"></head>
<body class="layout-container" data-ice="rootContainer">
<header>
<a href="./">Home</a>
<a href="identifiers.html">Reference</a>
<a href="source.html">Source</a>
<div class="search-box">
<span>
<img src="./image/search.png">
<span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
</span>
<ul class="search-result"></ul>
</div>
<a style="position:relative; top:3px;" href="https://github.com/hodgef/simple-keyboard"><img width="20px" src="./image/github.png"></a></header>
<nav class="navigation" data-ice="nav"><div>
<ul>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#demo">demo</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/demo/App.js~App.html">App</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#lib-components">lib/components</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/lib/components/Keyboard.js~SimpleKeyboard.html">SimpleKeyboard</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#lib-services">lib/services</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/lib/services/KeyboardLayout.js~KeyboardLayout.html">KeyboardLayout</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/lib/services/PhysicalKeyboard.js~PhysicalKeyboard.html">PhysicalKeyboard</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/lib/services/Utilities.js~Utilities.html">Utilities</a></span></span></li>
<li data-ice="doc"><a data-ice="dirPath" class="nav-dir-path" href="identifiers.html#lib-tests">lib/tests</a><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/lib/tests/TestUtility.js~TestUtility.html">TestUtility</a></span></span></li>
</ul>
</div>
</nav>
<div class="content" data-ice="content"><h1 data-ice="title">src/demo/App.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import Keyboard from &apos;../lib&apos;;
import &apos;./css/App.css&apos;;
/**
* simple-keyboard demo
*/
class App {
/**
* Instantiates the demo class
*/
constructor(){
document.addEventListener(&apos;DOMContentLoaded&apos;, this.onDOMLoaded);
/**
* Default input name
* @type {string}
*/
this.layoutName = &quot;default&quot;;
}
/**
* Executed when the DOM is ready
*/
onDOMLoaded = () =&gt; {
/**
* Creates a new simple-keyboard instance
*/
this.keyboard = new Keyboard({
debug: true,
layoutName: this.layoutName,
onChange: input =&gt; this.onChange(input),
onKeyPress: button =&gt; this.onKeyPress(button),
newLineOnEnter: true,
physicalKeyboardHighlight: true,
});
/**
* Adding preview (demo only)
*/
document.querySelector(&apos;.simple-keyboard&apos;).insertAdjacentHTML(&apos;beforebegin&apos;, `
&lt;div class=&quot;simple-keyboard-preview&quot;&gt;
&lt;textarea class=&quot;input&quot;&gt;&lt;/textarea&gt;
&lt;/div&gt;
`);
document.querySelector(&apos;.input&apos;).addEventListener(&apos;change&apos;, (event) =&gt; {
this.keyboard.setInput(event.target.value);
});
console.log(this.keyboard);
}
/**
*
*/
handleShiftButton = () =&gt; {
let layoutName = this.layoutName;
let shiftToggle = this.layoutName = layoutName === &quot;default&quot; ? &quot;shift&quot; : &quot;default&quot;;
this.keyboard.setOptions({
layoutName: shiftToggle
});
}
/**
* Called when simple-keyboard input has changed
*/
onChange = input =&gt; {
document.querySelector(&apos;.input&apos;).value = input;
}
/**
* Called when a simple-keyboard key is pressed
*/
onKeyPress = button =&gt; {
console.log(&quot;Button pressed&quot;, button);
/**
* Shift functionality
*/
if(button === &quot;{lock}&quot; || button === &quot;{shift}&quot;)
this.handleShiftButton();
}
}
export default App;</code></pre>
</div>
<footer class="footer">
Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.1.0)</span><img src="./image/esdoc-logo-mini-black.png"></a>
</footer>
<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>