index.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Virtual Keyboard</title>
  6. <!-- jQuery (required) & jQuery UI + theme (optional) -->
  7. <link href="docs/css/jquery-ui.min.css" rel="stylesheet">
  8. <!-- still using jQuery v2.2.4 because Bootstrap doesn't support v3+ -->
  9. <script src="docs/js/jquery-latest.min.js"></script>
  10. <script src="docs/js/jquery-ui.min.js"></script>
  11. <!-- <script src="docs/js/jquery-migrate-3.0.0.min.js"></script> -->
  12. <!-- keyboard widget css & script (required) -->
  13. <link href="css/keyboard.css" rel="stylesheet">
  14. <script src="js/jquery.keyboard.js"></script>
  15. <!-- keyboard extensions (optional) -->
  16. <script src="js/jquery.mousewheel.js"></script>
  17. <script src="js/jquery.keyboard.extension-typing.js"></script>
  18. <script src="js/jquery.keyboard.extension-autocomplete.js"></script>
  19. <script src="js/jquery.keyboard.extension-caret.js"></script>
  20. <!-- demo only -->
  21. <link rel="stylesheet" href="docs/css/bootstrap.min.css">
  22. <link rel="stylesheet" href="docs/css/font-awesome.min.css">
  23. <link href="docs/css/demo.css" rel="stylesheet">
  24. <link href="docs/css/tipsy.css" rel="stylesheet">
  25. <link href="docs/css/prettify.css" rel="stylesheet">
  26. <script src="docs/js/bootstrap.min.js"></script>
  27. <script src="docs/js/demo.js"></script>
  28. <script src="docs/js/jquery.tipsy.min.js"></script>
  29. <script src="docs/js/prettify.js"></script> <!-- syntax highlighting -->
  30. </head>
  31. <body>
  32. <nav class="navbar navbar-default">
  33. <div class="container-fluid">
  34. <div class="navbar-header">
  35. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  36. <span class="sr-only">Toggle navigation</span>
  37. <span class="icon-bar"></span>
  38. <span class="icon-bar"></span>
  39. <span class="icon-bar"></span>
  40. </button>
  41. <a class="navbar-brand" name="top">
  42. <span class="fa fa-keyboard-o fa-lg"></span>
  43. </a>
  44. </div>
  45. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  46. <ul class="nav navbar-nav">
  47. <li class="active"><a href="#">Home <span class="sr-only">(current)</span></a></li>
  48. <li><a href="docs/basic.html">Basic</a></li>
  49. <li class="dropdown">
  50. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Layouts <span class="caret"></span></a>
  51. <ul class="dropdown-menu">
  52. <li><a href="docs/layouts.html">Standard</a></li>
  53. <li><a href="docs/layouts2.html">Greywyvern</a></li>
  54. <li><a href="docs/layouts3.html">Microsoft Keyboard</a></li>
  55. <li><a href="docs/calculator.html"><span class="fa fa-calculator fa-lg"></span> Calculator</a></li>
  56. </ul>
  57. </li>
  58. <li class="dropdown">
  59. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Extensions <span class="caret"></span></a>
  60. <ul class="dropdown-menu">
  61. <li><a href="docs/altkeys-popup.html">Alt-keys</a></li>
  62. <li><a href="#autocomplete">Autocomplete</a></li>
  63. <li><a href="#caret">Caret</a></li>
  64. <li><a href="docs/extender.html">Extender</a></li>
  65. <li><a href="docs/preview-keyset.html">Keyset</a></li>
  66. <li><a href="docs/mobile.html">Mobile</a></li>
  67. <li><a href="docs/jquery-mobile-1.4.html">Mobile v1.4</a></li>
  68. <li><a href="docs/navigate.html">Navigate</a></li>
  69. <li><a href="docs/scramble.html">Scramble</a></li>
  70. <li><a href="#typing">Typing</a></li>
  71. </ul>
  72. </li>
  73. <li><a href="https://jsfiddle.net/Mottie/egb3a1sk/"><span class="fa fa-flask fa-lg"></span> Playground</a></li>
  74. </ul>
  75. <ul class="nav navbar-nav navbar-right">
  76. <li><a href="https://github.com/Mottie/Keyboard"><span class="fa fa-github fa-lg" title="GitHub"></span></a></li>
  77. <li><a href="https://github.com/Mottie/Keyboard/archive/master.zip"><span class="fa fa-download fa-lg" title="Download"></span></a></li>
  78. <li><a href="https://github.com/Mottie/Keyboard/wiki"><span class="fa fa-file-text-o fa-lg" title="Documentation"></span></a></li>
  79. <li><a href="https://github.com/Mottie/Keyboard/issues"><span class="fa fa-bug fa-lg" title="Issues"></span></a></li>
  80. </ul>
  81. </div><!-- /.navbar-collapse -->
  82. </div><!-- /.container-fluid -->
  83. </nav>
  84. <div id="page-wrap">
  85. <h1>
  86. <a href="https://github.com/Mottie/Keyboard">Virtual Keyboard</a><br>
  87. <small class="version"></small>
  88. </h1>
  89. <iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=Mottie&amp;repo=keyboard&amp;type=fork&amp;count=true" width="90" height="20" title="Fork on GitHub"></iframe>
  90. <iframe class="github-btn" src="https://ghbtns.com/github-btn.html?user=Mottie&amp;repo=keyboard&amp;type=watch&amp;count=true" width="100" height="20" title="Star on GitHub"></iframe>
  91. <h5>Original by
  92. <a class="external" href="https://jsatt.blogspot.com/2010/01/on-screen-keyboard-widget-using-jquery.html">Jeremy Satterfield</a>,
  93. updated &amp; maintained by <a class="external" href="https://wowmotty.blogspot.com/2010/11/jquery-ui-keyboard-widget.html">Rob Garrison</a>
  94. </h5>
  95. <ul id="console">
  96. <li>...</li>
  97. <li>...</li>
  98. <li>...</li>
  99. <li>...</li>
  100. <li>...</li>
  101. </ul>
  102. <h5>
  103. Click inside the input or textarea to open the keyboard<br>
  104. Click on the keyboard title, then scroll down to see its code
  105. </h5>
  106. <div class="block">
  107. <h2>
  108. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Contenteditable</span>
  109. </h2>
  110. <div id="contenteditable" contenteditable="true">This
  111. is a <em>content editable</em> div with a custom keyboard
  112. <strong>layout</strong>. Press <kbd>Enter</kbd> to add new lines.</div>
  113. <br>
  114. <small>
  115. * Contenteditable support (v1.27.0-beta).<br>
  116. * <code>usePreview</code> disabled.<br>
  117. * Custom layout used.
  118. </small>
  119. <div class="code ui-corner-all">
  120. <h4>HTML</h4>
  121. <pre class="prettyprint lang-html">&lt;div id="contenteditable" contenteditable="true"&gt;This
  122. is a &lt;em&gt;content editable&lt;/em&gt; div with a custom keyboard
  123. &lt;strong&gt;layout&lt;/strong&gt;. Press &lt;kbd&gt;Enter&lt;/kbd&gt; to add new lines.&lt;/div&gt;</pre>
  124. <h4>Script</h4>
  125. <pre class="prettyprint lang-js">$.keyboard.keyaction.undo = function (base) {
  126. base.execCommand('undo');
  127. return false;
  128. };
  129. $.keyboard.keyaction.redo = function (base) {
  130. base.execCommand('redo');
  131. return false;
  132. };
  133. $('#contenteditable').keyboard({
  134. usePreview: true, // disabled for contenteditable
  135. useCombos: false,
  136. autoAccept: true,
  137. layout: 'custom',
  138. customLayout: {
  139. 'normal': [
  140. '` 1 2 3 4 5 6 7 8 9 0 - = {del} {b}',
  141. '{tab} q w e r t y u i o p [ ] \\',
  142. 'a s d f g h j k l ; \' {enter}',
  143. '{shift} z x c v b n m , . / {shift}',
  144. '{accept} {space} {left} {right} {undo:Undo} {redo:Redo}'
  145. ],
  146. 'shift': [
  147. '~ ! @ # $ % ^ & * ( ) _ + {del} {b}',
  148. '{tab} Q W E R T Y U I O P { } |',
  149. 'A S D F G H J K L : " {enter}',
  150. '{shift} Z X C V B N M < > ? {shift}',
  151. '{accept} {space} {left} {right} {undo:Undo} {redo:Redo}'
  152. ]
  153. },
  154. display: {
  155. del: '\u2326:Delete',
  156. redo: '↻',
  157. undo: '↺'
  158. }
  159. })
  160. .addTyping();</pre>
  161. </div>
  162. </div>
  163. <div class="block" id="autocomplete">
  164. <h2>
  165. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">QWERTY Text</span>
  166. </h2>
  167. <input id="text" type="text" placeholder=" Enter something...">
  168. <br>
  169. <small>
  170. * Placeholder (watermark).<br>
  171. * <a href="https://github.com/Mottie/Keyboard/wiki/Extension-Autocomplete">Autocomplete</a> extension.
  172. </small>
  173. <div class="code ui-corner-all">
  174. <h4>HTML</h4>
  175. <pre class="prettyprint lang-html">&lt;input id="text" type="text" placeholder=" Enter something..."&gt;</pre>
  176. <h4>Script</h4>
  177. <pre class="prettyprint lang-js">// Autocomplete demo
  178. var availableTags = ["ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure",
  179. "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript",
  180. "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ];
  181. $('#text')
  182. .keyboard({ layout: 'qwerty' })
  183. .autocomplete({
  184. source: availableTags
  185. })
  186. // position options added after v1.23.4
  187. .addAutocomplete({
  188. position : {
  189. of : null, // when null, element will default to kb.$keyboard
  190. my : 'right top', // 'center top', (position under keyboard)
  191. at : 'left top', // 'center bottom',
  192. collision: 'flip'
  193. }
  194. })
  195. .addTyping();</pre>
  196. </div>
  197. </div>
  198. <div class="block">
  199. <h2>
  200. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">QWERTY Password</span>
  201. <img id="password-opener" class="tooltip-tipsy" title="Click to open the virtual keyboard" src="css/images/keyboard.svg">
  202. </h2>
  203. <input id="password" type="password">
  204. <br>
  205. <small>
  206. * Click icon to open keyboard.<br>
  207. * Stay open until accept/cancel/esc.<br>
  208. * Key hover disabled in this type.<br>
  209. * Demo: Reveal letters with <a class="external" href="https://jsfiddle.net/Mottie/24n8wsak/">Caret extension</a>.
  210. </small>
  211. <div class="code ui-corner-all">
  212. <h4>HTML</h4>
  213. <pre class="prettyprint lang-html">&lt;img id="passwd" class="tooltip-tipsy" title="Click to open the virtual keyboard" src="css/images/keyboard.svg"&gt;
  214. &lt;input id="password" type="password"&gt;</pre>
  215. <h4>Script</h4>
  216. <pre class="prettyprint lang-js">$('#password')
  217. .keyboard({
  218. openOn : null,
  219. stayOpen : true,
  220. layout : 'qwerty'
  221. })
  222. .addTyping();
  223. $('#password-opener').click(function(){
  224. var kb = $('#password').getkeyboard();
  225. // close the keyboard if the keyboard is visible and the button is clicked a second time
  226. if ( kb.isOpen ) {
  227. kb.close();
  228. } else {
  229. kb.reveal();
  230. }
  231. });</pre>
  232. </div>
  233. </div>
  234. <div class="block" id="caret">
  235. <h2>
  236. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">QWERTY (mod) Text Area</span>
  237. </h2>
  238. <textarea id="qwerty-mod"></textarea>
  239. <br>
  240. <small>
  241. * Locked input (no manual input).<br>
  242. * Known readonly bug in Safari.<br>
  243. * <a href="https://github.com/Mottie/Keyboard/wiki/Extension-Caret">Caret</a> extension.
  244. </small>
  245. <div class="code ui-corner-all">
  246. <h4>HTML</h4>
  247. <pre class="prettyprint lang-html">&lt;textarea id="qwerty-mod"&gt;&lt;/textarea&gt;</pre>
  248. <h4>Script</h4>
  249. <pre class="prettyprint lang-js">$('#qwerty-mod')
  250. .keyboard({
  251. lockInput: true, // prevent manual keyboard entry
  252. layout: 'custom',
  253. customLayout: {
  254. 'normal': [
  255. '` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
  256. '{tab} q w e r t y u i o p [ ] \\',
  257. 'a s d f g h j k l ; \' {enter}',
  258. '{shift} z x c v b n m , . / {shift}',
  259. '{accept} {space} {left} {right}'
  260. ],
  261. 'shift': [
  262. '~ ! @ # $ % ^ & * ( ) _ + {bksp}',
  263. '{tab} Q W E R T Y U I O P { } |',
  264. 'A S D F G H J K L : " {enter}',
  265. '{shift} Z X C V B N M &lt; &gt; ? {shift}',
  266. '{accept} {space} {left} {right}'
  267. ]
  268. }
  269. })
  270. .addCaret({
  271. // extra class name added to the caret
  272. // "ui-keyboard-caret" class is always added
  273. caretClass : '',
  274. // *** for future use ***
  275. // data-attribute containing the character(s) next to the caret
  276. charAttr : 'data-character',
  277. // # character(s) next to the caret (can be negative for RTL)
  278. charIndex : 1,
  279. // caret position adjustments
  280. offsetX : 0,
  281. offsetY : 0
  282. })
  283. .addTyping();</pre>
  284. <h4>CSS</h4>
  285. <pre class="prettyprint lang-css">.ui-keyboard-caret {
  286. background: #c00;
  287. width: 1px;
  288. margin-top: 3px;
  289. }</pre>
  290. </div>
  291. </div>
  292. <div class="block" id="typing">
  293. <h2>
  294. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">International</span>
  295. <img id="inter-type" class="tooltip-tipsy" title="Try out the typing extension!" src="css/images/keyboard.svg">
  296. </h2>
  297. <textarea id="inter"></textarea>
  298. <br>
  299. <small>
  300. * <a class="external" href="https://bootswatch.com/darkly/">Bootswatch Darkly</a> theme.<br>
  301. * <a href="https://github.com/Mottie/Keyboard/wiki/Extension-Typing">Typing</a> extension.<br>
  302. * See basic non-library <a class="external" href="https://jsfiddle.net/Mottie/jsh0377k/">theme</a>.
  303. </small>
  304. <div class="code ui-corner-all">
  305. <h4>HTML</h4>
  306. <pre class="prettyprint lang-html">&lt;img id="inter-type" class="tooltip-tipsy" title="Try out the typing extension!" src="css/images/keyboard.svg"&gt;
  307. &lt;textarea id="inter"&gt;&lt;/textarea&gt;</pre>
  308. <h4>CSS</h4>
  309. <pre class="prettyprint lang-css">/* override bootstrap active state */
  310. button.btn-default:active {
  311. background-color: #FFF;
  312. -webkit-box-shadow: none;
  313. box-shadow: none;
  314. }
  315. button.btn-default:active:hover {
  316. background-color: #3276B1;
  317. }
  318. /* override Bootstrap excessive button padding */
  319. button.ui-keyboard-button.btn {
  320. padding: 1px 6px;
  321. }
  322. /* Bootswatch Darkly input is too bright */
  323. .ui-keyboard-input.light, .ui-keyboard-preview.light { color: #222; background: #ddd; }
  324. .ui-keyboard-input.dark, .ui-keyboard-preview.dark { color: #ddd; background: #222; }
  325. </pre>
  326. <h4>Script</h4>
  327. <pre class="prettyprint lang-js">$('#inter')
  328. .keyboard({
  329. layout: 'international',
  330. css: {
  331. // input & preview
  332. // "label-default" for a darker background
  333. // "light" for white text
  334. input: 'form-control input-sm dark',
  335. // keyboard container
  336. container: 'center-block well',
  337. // default state
  338. buttonDefault: 'btn btn-default',
  339. // hovered button
  340. buttonHover: 'btn-primary',
  341. // Action keys (e.g. Accept, Cancel, Tab, etc);
  342. // this replaces "actionClass" option
  343. buttonAction: 'active',
  344. // used when disabling the decimal button {dec}
  345. // when a decimal exists in the input area
  346. buttonDisabled: 'disabled'
  347. }
  348. })
  349. .addTyping();
  350. // Script - typing extension
  351. // simulate typing into the keyboard, use:
  352. // \t or {t} = tab, \b or {b} = backspace, \r or \n or {e} = enter
  353. // added {l} = caret left, {r} = caret right & {d} = delete
  354. $('#inter-type').click(function(){
  355. $('#inter').getkeyboard().reveal().typeIn("{t}Hal{l}{l}{d}e{r}{r}l'o{b}o {e}{t}World", 500);
  356. return false;
  357. });</pre>
  358. </div>
  359. </div>
  360. <div class="block">
  361. <h2>
  362. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Alphabetical</span>
  363. </h2>
  364. <textarea id="alpha"></textarea>
  365. <div class="code ui-corner-all">
  366. <h4>HTML</h4>
  367. <pre class="prettyprint lang-html">&lt;textarea id="alpha"&gt;&lt;/textarea&gt;</pre>
  368. <h4>Script</h4>
  369. <pre class="prettyprint lang-js">$('#alpha')
  370. .keyboard({ layout: 'alpha' })
  371. .addTyping();</pre>
  372. </div>
  373. </div>
  374. <div class="block">
  375. <h2>
  376. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Colemak</span>
  377. </h2>
  378. <textarea id="colemak"></textarea>
  379. <div class="code ui-corner-all">
  380. <h4>HTML</h4>
  381. <pre class="prettyprint lang-html">&lt;textarea id="colemak"&gt;&lt;/textarea&gt;</pre>
  382. <h4>Script</h4>
  383. <pre class="prettyprint lang-js">$('#colemak')
  384. .keyboard({ layout: 'colemak' })
  385. .addTyping();</pre>
  386. </div>
  387. </div>
  388. <div class="block">
  389. <h2>
  390. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Dvorak</span>
  391. </h2>
  392. <textarea id="dvorak"></textarea>
  393. <div class="code ui-corner-all">
  394. <h4>HTML</h4>
  395. <pre class="prettyprint lang-html">&lt;textarea id="dvorak"&gt;&lt;/textarea&gt;</pre>
  396. <h4>Script</h4>
  397. <pre class="prettyprint lang-js">$('#dvorak')
  398. .keyboard({ layout: 'dvorak' })
  399. .addTyping();</pre>
  400. </div>
  401. </div>
  402. <div class="block">
  403. <h2>
  404. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Num Pad</span>
  405. </h2>
  406. <input id="num" class="alignRight" type="text">
  407. <br>
  408. <small>
  409. * Input restricted.<br>
  410. * Pasting (ctrl-v) not allowed.<br>
  411. * Auto accept content.
  412. </small>
  413. <div class="code ui-corner-all">
  414. <h4>HTML</h4>
  415. <pre class="prettyprint lang-html">&lt;input id="num" class="alignRight" type="text"&gt;</pre>
  416. <h4>Script</h4>
  417. <pre class="prettyprint lang-js">$('#num')
  418. .keyboard({
  419. layout : 'num',
  420. restrictInput : true, // Prevent keys not in the displayed keyboard from being typed in
  421. preventPaste : true, // prevent ctrl-v and right click
  422. autoAccept : true
  423. })
  424. .addTyping();</pre>
  425. </div>
  426. </div>
  427. <div class="block">
  428. <h2>
  429. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Hex</span>
  430. </h2>
  431. <input id="hex" type="text">
  432. <br>
  433. <small>
  434. * maxLength = 6.<br>
  435. * Input restricted.<br>
  436. * Lowercase included.<br>
  437. * Valid @ length = 6.
  438. </small>
  439. <div class="code ui-corner-all">
  440. <h4>HTML</h4>
  441. <pre class="prettyprint lang-html">
  442. &lt;input id="hex" type="text"&gt;</pre>
  443. <h4>Script</h4>
  444. <pre class="prettyprint lang-js">$('#hex')
  445. .keyboard({
  446. layout: 'custom',
  447. customLayout: {
  448. 'normal' : [
  449. 'C D E F',
  450. '8 9 A B',
  451. '4 5 6 7',
  452. '0 1 2 3',
  453. '{bksp} {a} {c}'
  454. ]
  455. },
  456. maxLength : 6,
  457. // Prevent keys not in the displayed keyboard from being typed in
  458. restrictInput : true,
  459. // include lower case characters (added v1.25.7)
  460. restrictInclude : 'a b c d e f',
  461. // don't use combos or A+E could become a ligature
  462. useCombos : false,
  463. // activate the "validate" callback function
  464. acceptValid : true,
  465. validate : function(keyboard, value, isClosing){
  466. // only make valid if input is 6 characters in length
  467. return value.length === 6;
  468. }
  469. })
  470. .addTyping();</pre>
  471. </div>
  472. </div>
  473. <div class="block">
  474. <h2>
  475. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Meta Sets</span>
  476. <img id="meta-type" class="tooltip-tipsy" title="Try out the typing extension!" src="css/images/keyboard.svg">
  477. </h2>
  478. <textarea id="meta"></textarea>
  479. <br>
  480. <small>
  481. * <a href="https://github.com/Mottie/Keyboard/wiki/Extension-Typing">Typing</a> extension.<br>
  482. * Keyboard opens showing last keyset.<br>
  483. * userClosed set (accept/cancel to close).
  484. </small>
  485. <div class="code ui-corner-all">
  486. <h4>HTML</h4>
  487. <pre class="prettyprint lang-html">&lt;textarea id="meta"&gt;&lt;/textarea&gt;</pre>
  488. <h4>Script</h4>
  489. <pre class="prettyprint lang-js">$('#meta')
  490. .keyboard({
  491. // keyboard will open showing last key set used
  492. resetDefault: false,
  493. userClosed: true, // keyboard open until user closes with accept or cancel
  494. autoAccept: true, // required for userClosed: true
  495. layout: 'custom',
  496. display: {
  497. 'alt' : 'AltGr:It\'s all Greek to me',
  498. // in v1.26.8, meta keys can be named `meta` followed by any letter, underscore or dash.
  499. // older versions would only allow the name `meta` followed by a number, then any letter or underscore
  500. // see https://github.com/Mottie/Keyboard/issues/504
  501. 'meta1' : '\u2666:end of alphabet', // Diamond with label that shows in the title (spaces are okay here)
  502. 'meta-2' : '\u2665:Russian', // Heart
  503. 'meta3' : '\u2663:zodiac', // Club
  504. 'meta_9' : '\u2660:numbers' // Spade
  505. },
  506. customLayout: {
  507. 'normal' : [
  508. // Add labels using a ":" after the key's name and replace spaces with "_"
  509. // without the labels this line is just 'a b c d e f g'
  510. 'a:a_letter,_that_sounds_like_"ey" b:a_bug_that_makes_honey c:is_when_I_look_around d:a_grade,_I_never_got e:is_what_girls_say_when_they_run_away_from_me f:u,_is_what_I_say_to_those_screaming_girls! g:gee,_is_that_the_end_of_my_wittiness?',
  511. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  512. '{bksp} {sp:1} {accept} {cancel}'
  513. ],
  514. 'shift' : [
  515. 'A B C D E F G',
  516. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  517. '{bksp} {sp:1} {accept} {cancel}'
  518. ],
  519. 'alt' : [
  520. '\u03b1 \u03b2 \u03b3 \u03b4 \u03b5 \u03b6 \u03b7', // lower case Greek
  521. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  522. '{bksp} {sp:1} {accept} {cancel}'
  523. ],
  524. 'alt-shift' : [
  525. '\u0391 \u0392 \u0393 \u0394 \u0395 \u0396 \u0397', // upper case Greek
  526. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  527. '{bksp} {sp:1} {accept} {cancel}'
  528. ],
  529. 'meta1' : [
  530. 't u v w x y z', // lower case end of alphabet
  531. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  532. '{bksp} {sp:1} {accept} {cancel}'
  533. ],
  534. 'meta1-shift' : [
  535. 'T U V W X Y Z', // upper case
  536. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  537. '{bksp} {sp:1} {accept} {cancel}'
  538. ],
  539. 'meta1-alt' : [
  540. '0 9 8 7 6 5 4', // numbers
  541. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  542. '{bksp} {sp:1} {accept} {cancel}'
  543. ],
  544. 'meta1-alt-shift' : [
  545. ') ( * & ^ % $', // shifted numbers
  546. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  547. '{bksp} {sp:1} {accept} {cancel}'
  548. ],
  549. 'meta-2' : [
  550. '\u0430 \u0431 \u0432 \u0433 \u0434 \u0435 \u0436', // lower case Russian
  551. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  552. '{bksp} {sp:1} {accept} {cancel}'
  553. ],
  554. 'meta-2-shift' : [
  555. '\u0410 \u0411 \u0412 \u0413 \u0414 \u0415 \u0416', // upper case Russian
  556. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  557. '{bksp} {sp:1} {accept} {cancel}'
  558. ],
  559. 'meta3' : [
  560. '\u2648 \u2649 \u264A \u264B \u264C \u264D \u264E', // Zodiac
  561. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  562. '{bksp} {sp:1} {accept} {cancel}'
  563. ],
  564. 'meta_9' : [
  565. '1 2 3 4 5 6 7', // only because I ran out of ideas
  566. '{shift} {alt} {meta1} {meta-2} {meta3} {meta_9}',
  567. '{bksp} {sp:1} {accept} {cancel}'
  568. ]
  569. }
  570. })
  571. .addTyping();
  572. // Script - typing extension
  573. var meta = $('#meta').getkeyboard();
  574. meta
  575. .reveal()
  576. .typeIn('aBcD1112389\u0411\u2648\u2649', 700, function(){
  577. meta.accept();
  578. alert('all done!');
  579. });</pre>
  580. </div>
  581. </div>
  582. <div class="block">
  583. <h2>
  584. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Junk</span>
  585. </h2>
  586. <textarea id="junk"></textarea>
  587. <br>
  588. <small>
  589. * Use shift key - see action key sizes.<br>
  590. * Use the decimal - only one allowed.<br>
  591. * Toggle combo key included.<br>
  592. * Type in 'ae' and other combo keys.<br>
  593. * Accept content to see the callback.
  594. </small>
  595. <div class="code ui-corner-all">
  596. <h4>HTML</h4>
  597. <pre class="prettyprint lang-html">&lt;textarea id="junk"&gt;&lt;/textarea&gt;</pre>
  598. <h4>Script</h4>
  599. <pre class="prettyprint lang-js">$('#junk')
  600. .keyboard({
  601. layout: 'custom',
  602. customLayout: {
  603. 'normal' : [
  604. 'a e i o u y c',
  605. '` \' " ~ ^ {dec} {combo}',
  606. '{tab} {enter} {bksp}',
  607. '{space}',
  608. '{accept} {cancel} {shift}'
  609. ],
  610. 'shift' : [
  611. 'A E I O U Y C',
  612. '` \' " ~ ^ {dec} {combo}',
  613. '{t} {sp:1} {e} {sp:1} {b}',
  614. '{space}',
  615. '{a} {sp:1} {c} {sp:1} {s}'
  616. ]
  617. },
  618. // Added here as an example on how to add combos
  619. combos : {
  620. 'a' : { e: '\u00e6' },
  621. 'A' : { E: '\u00c6' }
  622. },
  623. // example callback function
  624. accepted : function(e, keyboard, el){ alert('The content "' + el.value + '" was accepted!'); }
  625. })
  626. .addTyping();</pre>
  627. </div>
  628. </div>
  629. <div class="block">
  630. <h2>
  631. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Mapped Keys</span>
  632. </h2>
  633. <textarea id="map"></textarea>
  634. <br>
  635. <small>
  636. * No preview window.<br>
  637. * Type in a-g.<br>
  638. * Type in A-G (shifted).<br>
  639. </small>
  640. <div class="code ui-corner-all">
  641. <h4>HTML</h4>
  642. <pre class="prettyprint lang-html">&lt;textarea id="map"&gt;&lt;/textarea&gt;</pre>
  643. <h4>Script</h4>
  644. <pre class="prettyprint lang-js">// *** Mapped keys ***
  645. $('#map').keyboard({
  646. layout: 'custom',
  647. customLayout: {
  648. 'normal' : [
  649. // "n(a):title_or_tooltip"; n = new key, (a) = actual key, ":label" = title_or_tooltip (use an underscore "_" in place of a space " ")
  650. '\u03b1(a):lower_case_alpha_(type_a) \u03b2(b):lower_case_beta_(type_b) \u03b3(c):lower_case_gamma_(type_c) \u03b4(d):lower_case_delta_(type_d) \u03b5(e):lower_case_epsilon_(type_e) \u03b6(f):lower_case_zeta_(type_f) \u03b7(g):lower_case_eta_(type_g)', // lower case Greek
  651. '{shift} {accept} {cancel}'
  652. ],
  653. 'shift' : [
  654. '\u0391(A) \u0392(B) \u0393(C) \u0394(D) \u0395(E) \u0396(F) \u0397(G)', // upper case Greek
  655. '{shift} {accept} {cancel}'
  656. ]
  657. },
  658. usePreview: false // no preveiw
  659. });</pre>
  660. </div>
  661. </div>
  662. <div class="block">
  663. <h2>
  664. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Hidden</span>
  665. </h2>
  666. <a href="#" class="hiddenInput">Hidden input</a>
  667. <!-- DON'T use type="hidden" because IE doesn't like hidden inputs -->
  668. <input id="hidden" type="text" style="display:none;">
  669. <div class="code ui-corner-all">
  670. <h4>HTML</h4>
  671. <pre class="prettyprint lang-html">&lt;a href="#" class="hiddenInput"&gt;Hidden input&lt;/a&gt;
  672. &lt;!-- DON'T use type="hidden" because IE doesn't like hidden inputs --&gt;
  673. &lt;input id="hidden" type="text" style="display:none;"&gt;</pre>
  674. <h4>Script</h4>
  675. <pre class="prettyprint lang-js">// *** Hidden input example ***
  676. // click on a link - add focus to hidden input
  677. $('.hiddenInput').click(function(){
  678. $('#hidden').data('keyboard').reveal();
  679. return false;
  680. });
  681. // Initialize keyboard script on hidden input
  682. // set "position.of" to the same link as above
  683. $('#hidden')
  684. .keyboard({
  685. layout : 'qwerty',
  686. position : {
  687. of : $('.hiddenInput'),
  688. my : 'center top',
  689. at : 'center top'
  690. }
  691. })
  692. .addTyping();</pre>
  693. </div>
  694. </div>
  695. <div class="block">
  696. <h2>
  697. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: iPad</span>
  698. </h2>
  699. <textarea id="ipad"></textarea>
  700. <br>
  701. <small>
  702. * Thanks to <a class="external" href="https://github.com/gitaarik">gitaarik</a> for sharing!.
  703. </small>
  704. <div class="code ui-corner-all">
  705. <h4>HTML</h4>
  706. <pre class="prettyprint lang-html">&lt;textarea id="ipad"&gt;&lt;/textarea&gt;</pre>
  707. <h4>Script</h4>
  708. <pre class="prettyprint lang-js">$('#ipad').keyboard({
  709. display: {
  710. 'bksp' : "\u2190",
  711. 'accept' : 'return',
  712. 'normal' : 'ABC',
  713. 'meta1' : '.?123',
  714. 'meta2' : '#+='
  715. },
  716. layout: 'custom',
  717. customLayout: {
  718. 'normal': [
  719. 'q w e r t y u i o p {bksp}',
  720. 'a s d f g h j k l {enter}',
  721. '{s} z x c v b n m , . {s}',
  722. '{meta1} {space} {meta1} {accept}'
  723. ],
  724. 'shift': [
  725. 'Q W E R T Y U I O P {bksp}',
  726. 'A S D F G H J K L {enter}',
  727. '{s} Z X C V B N M ! ? {s}',
  728. '{meta1} {space} {meta1} {accept}'
  729. ],
  730. 'meta1': [
  731. '1 2 3 4 5 6 7 8 9 0 {bksp}',
  732. '- / : ; ( ) \u20ac & @ {enter}',
  733. '{meta2} . , ? ! \' " {meta2}',
  734. '{normal} {space} {normal} {accept}'
  735. ],
  736. 'meta2': [
  737. '[ ] { } # % ^ * + = {bksp}',
  738. '_ \\ | ~ &lt; &gt; $ \u00a3 \u00a5 {enter}',
  739. '{meta1} . , ? ! \' " {meta1}',
  740. '{normal} {space} {normal} {accept}'
  741. ]
  742. }
  743. });</pre>
  744. </div>
  745. </div>
  746. <div class="block">
  747. <h2>
  748. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: iPad email</span>
  749. </h2>
  750. <textarea id="ipad-email"></textarea>
  751. <br>
  752. <small>
  753. * Thanks to <a class="external" href="https://github.com/gitaarik">gitaarik</a> for sharing!.
  754. </small>
  755. <div class="code ui-corner-all">
  756. <h4>HTML</h4>
  757. <pre class="prettyprint lang-html">&lt;textarea id="ipad-email"&gt;&lt;/textarea&gt;</pre>
  758. <h4>Script</h4>
  759. <pre class="prettyprint lang-js">$('#ipad-email').keyboard({
  760. display: {
  761. 'bksp' : '\u2190',
  762. 'enter' : 'return',
  763. 'normal' : 'ABC',
  764. 'meta1' : '.?123',
  765. 'meta2' : '#+=',
  766. 'accept' : '\u21d3'
  767. },
  768. layout: 'custom',
  769. customLayout: {
  770. 'normal': [
  771. 'q w e r t y u i o p {bksp}',
  772. 'a s d f g h j k l {enter}',
  773. '{s} z x c v b n m @ . {s}',
  774. '{meta1} {space} _ - {accept}'
  775. ],
  776. 'shift': [
  777. 'Q W E R T Y U I O P {bksp}',
  778. 'A S D F G H J K L {enter}',
  779. '{s} Z X C V B N M @ . {s}',
  780. '{meta1} {space} _ - {accept}'
  781. ],
  782. 'meta1': [
  783. '1 2 3 4 5 6 7 8 9 0 {bksp}',
  784. '` | { } % ^ * / \' {enter}',
  785. '{meta2} $ & ~ # = + . {meta2}',
  786. '{normal} {space} ! ? {accept}'
  787. ],
  788. 'meta2': [
  789. '[ ] { } \u2039 \u203a ^ * " , {bksp}',
  790. '\\ | / &lt; &gt; $ \u00a3 \u00a5 \u2022 {enter}',
  791. '{meta1} \u20ac & ~ # = + . {meta1}',
  792. '{normal} {space} ! ? {accept}'
  793. ]
  794. }
  795. });</pre>
  796. </div>
  797. </div>
  798. <div class="block">
  799. <h2>
  800. <span class="tooltip-tipsy" title="Click, then scroll down to see this code">Custom: Lockable</span>
  801. </h2>
  802. <input id="lockable" type="text">
  803. <br>
  804. <small>
  805. * cursor arrow keys.<br>
  806. * keyboard enable/disable toggle.<br>
  807. * include {del} key (opposite of {bksp})
  808. </small>
  809. <div class="code ui-corner-all">
  810. <h4>HTML</h4>
  811. <pre class="prettyprint lang-html">&lt;input id="lockable" type="text"&gt;</pre>
  812. <h4>Script</h4>
  813. <pre class="prettyprint lang-js">$('#lockable').keyboard({
  814. layout: 'custom',
  815. customLayout: {
  816. 'normal': [
  817. '` 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
  818. '{tab} q w e r t y u i o p [ ] \\',
  819. 'a s d f g h j k l ; \' {enter}',
  820. '{shift} z x c v b n m , . / {shift}',
  821. '{accept} {space} {left} {right} {sp:.2} {del} {toggle}'
  822. ],
  823. 'shift': [
  824. '~ ! @ # $ % ^ & * ( ) _ + {bksp}',
  825. '{tab} Q W E R T Y U I O P { } |',
  826. 'A S D F G H J K L : " {enter}',
  827. '{shift} Z X C V B N M &lt; &gt; ? {shift}',
  828. '{accept} {space} {left} {right} {sp:.2} {del} {toggle}'
  829. ]
  830. },
  831. css: {
  832. // add dark themed class to keyboard popup
  833. // to use bright svg padlock icon
  834. popup : 'ui-keyboard-dark-theme'
  835. }
  836. })
  837. .addTyping();</pre>
  838. </div>
  839. </div>
  840. <div id="showcode"></div>
  841. <div id="footer"></div>
  842. </div>
  843. </body></html>