-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
65 lines (60 loc) · 1.74 KB
/
demo.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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>On-Screen Keyboard Demo</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/accursoft/caret/master/jquery.caret.js"></script>
<script type="text/javascript" src="jquery.osk.js"></script>
<script type="text/javascript">
function callback(key) {
var box = $('#text');
var text = box.val();
var pos = box.caret();
switch (key) {
case '\b':
box.val(text.substring(0, pos-1) + text.substring(pos));
box.caret(pos-1);
break;
case '\3':
box.caret(pos-1);
break;
case '\4':
box.caret(pos+1);
break;
default:
box.val(text.substring(0, pos) + key + text.substring(pos));
box.caret(pos+1);
}
}
$(function() {
$('#basic').click(function() {$('#osk').loadLayout('layouts/us-basic.json', callback)});
$('#international').click(function() {$('#osk').loadLayout('layouts/us-international.json', callback)});
});
</script>
<style type="text/css">
#osk div {
text-align: center;
}
#osk button {
height: 1.5em;
min-width: 1.5em;
font-size: xx-large;
}
#key_spacebar {
width: 15em;
}
#osk.shift #key_leftshift,
#osk.shift #key_rightshift,
#osk.altGr #key_altgr,
#osk.capsLock #key_capslock {
background-color: #fd9;
}
</style>
</head>
<body>
<button id="basic">US Basic</button>
<button id="international">US International</button>
<p><textarea rows="5" cols="20" id="text"></textarea></p>
<div id="osk"></div>
</body>
</html>