-
Notifications
You must be signed in to change notification settings - Fork 3
/
0801.html
36 lines (32 loc) · 863 Bytes
/
0801.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<HTML>
<HEAD>
<TITLE>Keystroke detector</TITLE>
</HEAD>
<BODY>
<SCRIPT>
function checkKey(e){
if (e.keyCode == 84){
alert("You have dotted those eyes, but you can't put any Tees in the box!");
if (navigator.appName == "Microsoft Internet Explorer")
e.returnValue = false; //works with Explorer
else {
//deal with Navigator or Mozilla
str = document.theForm.theText.value;
if (str.length == 1)
newstr=" ";
else {
newstr = str.substring(0, str.length -1);
}
document.theForm.theText.value = newstr;
}
}
else {
alert ("You entered the character " + String.fromCharCode(e.keyCode) + ".");
}
}
</SCRIPT>
<FORM name="theForm">
<INPUT type=text name="theText" onKeyDown="checkKey(event);">
</FORM>
</BODY>
</HTML>