| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Typematic Test</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../themes/claro/document.css"; |
| 8 | @import "../themes/claro/claro.css"; |
| 9 | @import "css/dijitTests.css"; |
| 10 | </style> |
| 11 | |
| 12 | <script type="text/javascript" src="../../dojo/dojo.js" |
| 13 | data-dojo-config="isDebug: true"></script> |
| 14 | <script type="text/javascript"> |
| 15 | dojo.require("dijit.typematic"); |
| 16 | |
| 17 | var lastCount = 0; |
| 18 | function typematicCallBack(count, node, evt){ |
| 19 | var inputNode = dojo.byId('typematicInput'); |
| 20 | if(node == inputNode){ |
| 21 | key = "a"; |
| 22 | }else{ |
| 23 | key = "b"; |
| 24 | } |
| 25 | if(-1 == count){ |
| 26 | console.debug((lastCount + 1) + ' ' + key + ' events'); |
| 27 | }else{ |
| 28 | lastCount = count; |
| 29 | inputNode.value += key; |
| 30 | } |
| 31 | inputNode.focus(); |
| 32 | } |
| 33 | dojo.ready(function(){ |
| 34 | var keyNode = dojo.byId('typematicInput'); |
| 35 | var mouseNode = dojo.byId('typematicButton'); |
| 36 | dijit.typematic.addKeyListener(keyNode, |
| 37 | { |
| 38 | keyCode: dojo.keys.F11, |
| 39 | shiftKey: false, |
| 40 | metaKey: false, |
| 41 | ctrlKey: true // ALT is optional since its unspecified |
| 42 | }, |
| 43 | this, typematicCallBack, 200, 200); |
| 44 | dijit.typematic.addMouseListener(mouseNode, |
| 45 | this, typematicCallBack, 0.9, 200); |
| 46 | |
| 47 | try{ |
| 48 | // Focus the input so it's easier for user to start typing. |
| 49 | // Doesn't work well in IE6 though, when this test is loaded from robot/typematic.html, |
| 50 | // Apparently the robot code sets up a cover <div> over this page and IE doesn't want to focus |
| 51 | // the input since it's hidden. |
| 52 | keyNode.focus(); |
| 53 | }catch(e){ |
| 54 | } |
| 55 | }); |
| 56 | </script> |
| 57 | </head> |
| 58 | <body class="claro"> |
| 59 | |
| 60 | <h2>Dijit typematic tests</h2> |
| 61 | Press and hold the <b>ctrl+F11</b> keys (ALT optional, but not Shift or Meta) to see a's typed (constant rate) in the |
| 62 | input field,<br> |
| 63 | or left-mouse click the button and hold down to see b's typed (increasing rate) in the input field.<br> |
| 64 | <input id="typematicInput" size="500"> |
| 65 | <button id="typematicButton">to B or not to B</button> |
| 66 | |
| 67 | </body> |
| 68 | </html> |