-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyStrokeHeb.php
150 lines (145 loc) · 2.4 KB
/
keyStrokeHeb.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery.js"></script>
<script>
var input="";
$(document).unbind('keydown').bind('keydown', function (event) {
var doPrevent = false;
if (event.keyCode === 8) {
var d = event.srcElement || event.target;
if ((d.tagName.toUpperCase() === 'INPUT' && (d.type.toUpperCase() === 'TEXT' || d.type.toUpperCase() === 'PASSWORD'))
|| d.tagName.toUpperCase() === 'TEXTAREA') {
doPrevent = d.readOnly || d.disabled;
}
else {
doPrevent = true;
}
}
if (doPrevent) {
input = input.slice(0, -1);
var fieldNameElement = document.getElementById('key');
fieldNameElement.innerHTML = input;
event.preventDefault();
}
});
document.addEventListener('keydown', function(event) {
var keyStroke=event.keyCode;
switch (keyStroke)
{
case 8: //backspace
input = input.slice(0, -1);
break;
case 32: //space
x=" ";
break;
case 65: //A
x="ש";
break;
case 66: //B
x="נ";
break;
case 67: //C
x="ב";
break;
case 68: //D
x="ג";
break;
case 69: //E
x="ק";
break;
case 70: //F
x="כ";
break;
case 71: //G
x="ע";
break;
case 72: //H
x="י";
break;
case 73: //I
x="ן";
break;
case 74: //J
x="ח";
break;
case 75: //K
x="ל";
break;
case 76: //L
x="ך";
break;
case 77: //M
x="צ";
break;
case 78: //N
x="מ";
break;
case 79: //O
x="ם";
break;
case 80: //P
x="פ";
break;
case 81: //Q
x="/";
break;
case 82: //R
x="ר";
break;
case 83: //S
x="ד";
break;
case 84: //T
x="א";
break;
case 85: //U
x="ו";
break;
case 86: //V
x="ה";
break;
case 87: //W
x="'";
break;
case 88: //X
x="ס";
break;
case 89: //Y
x="ט";
break;
case 90: //Z
x="ז";
break;
case 190: //>
x="ץ";
break;
case 188: //<
x="ת";
break;
case 59: //;
x="ף";
break;
default:
x="";
break;
}
input = input + x;
var fieldNameElement = document.getElementById('key');
fieldNameElement.innerHTML = input;
}, true);
</script>
</head>
<body>
<div id="key" style="position:fixed;
z-index: 100;
top:50%;
left:50%;
margin:-100px 0 0 -100px;
width:200px;
height:200px; " >press a key</div>
</body>
</html>