diff options
| author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2006-08-24 16:37:21 +0000 |
|---|---|---|
| committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2006-08-24 16:37:21 +0000 |
| commit | ee598f26c9cfa4c642470f69a6f98549a40eae95 (patch) | |
| tree | 2dcb4103d702d30bf8331201d5209b31d9deaa13 /pexpect | |
| parent | 69dc16dad84521cd581da45f635ffc078a392200 (diff) | |
| download | pexpect-ee598f26c9cfa4c642470f69a6f98549a40eae95.tar.gz | |
Trying to capture keyboard is hard in javascript.
Diffstat (limited to 'pexpect')
| -rwxr-xr-x | pexpect/examples/bd_client.cgi | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/pexpect/examples/bd_client.cgi b/pexpect/examples/bd_client.cgi index edcc1e2..b0f363b 100755 --- a/pexpect/examples/bd_client.cgi +++ b/pexpect/examples/bd_client.cgi @@ -185,11 +185,33 @@ function update_button_colors () } } +function keyHandler(e) +{ + var pressedKey; + if (document.all) { e = window.event; } + if (document.layers) { pressedKey = e.which; } + if (document.all) { pressedKey = e.keyCode; } + pressedCharacter = String.fromCharCode(pressedKey); + type_key(pressedCharacter+pressedCharacter+pressedCharacter); + alert(pressedCharacter); +// alert(' Character = ' + pressedCharacter + ' [Decimal value = ' + pressedKey + ']'); +} +//document.onkeypress = keyHandler; +//if (document.layers) +// document.captureEvents(Event.KEYPRESS); +//http://sniptools.com/jskeys +document.onkeyup = KeyCheck; +function KeyCheck(e) +{ + var KeyID = (window.event) ? event.keyCode : e.keyCode; + type_key(String.fromCharCode(KeyID)); + e.cancelBubble = true; + window.event.cancelBubble = true; +} </script> </head> -<!-- <body onLoad="firstFocus()"> --> <body onload="init()"> <form id="form" name="form" action="/cgi-bin/bd_client.cgi" method="POST"> <input name="sid" value="%(SID)s" type="hidden"> |
