forked from zuriby/jquery.hotkeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-static-02.html
92 lines (84 loc) · 3.49 KB
/
test-static-02.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
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
<html>
<head>
<style>
* {font-family: mono; font-size:0.95em}
.eventNotifier{width: 100px; float: left; color:navy; border: dotted 1px navy; padding: 4px; background-color:white; margin:3px}
.dirty{border: solid 1px #0ca2ff; color:white; background-color:#0ca2ff}
</style>
</head>
<body>
<h3>Test #01</h3>
<input type='text' id='input_01'/>
<p>
type 'ctrl+l ' to focus.<br/>
type 'shift+3' to insert 'Shift#' into the text box.<br/>
type 'a' inside the textbox and have 'b' inserted instead.
</p>
<hr />
<h3>Test #02</h3>
<table>
<tbody>
<tr>
<td><input type='text' id='input_02' class='foo'></td>
</tr>
<tr>
<td><input type='text' id='input_03' class='foo'></td>
</tr>
<tr>
<td><input type='text' id='input_04' class='foo'></td>
</tr>
<tr>
<td><input type='text' id='input_05' class='foo'></td>
</tr>
<tr>
<td><input type='text' id='input_06' class='foo'></td>
</tr>
</tbody>
</table>
<input type='button' value='UnBind Click' onclick="unbindClick()" />
<input type='button' value='UnBind Keyup' onclick="unbindKeyup()" />
</body>
<hr />
<div id="logger"></div>
<script src="jquery-1.4.2.js"></script>
<script src="jquery.hotkeys.js"></script>
<script>
$(document).ready(function(){
$(document).bind('keydown', 'ctrl+l', function(){$('#input_01')[0].focus();})
.bind('keydown', 'shift+#', function(){$('#input_01')[0].value = "Shift#";})
.bind('keyup', 'a', function(event){
var v = $('#input_01')[0].value;
v = v.replace("a", "b");
v = $('#input_01')[0].value = v;
})
//.bind('keyup', function () { alert (arguments); })
.bind('click', function (event){
if (event.target == $('html')[0]){
alert("save the planet, don't waste energy over meaningless clicking");
}
});
$('input.foo').bind(
'keydown', {combi:'ctrl+k', disableInInput: false}, function(event){
log('binding keydown/ctrl+k to <b>input</b> applied on <b>#' + event.target.id + '</b>');
event.stopPropagation();
event.preventDefault();
}
);
$('table').bind('keydown click keyup', 'ctrl+l', clickHandler);
});
function clickHandler(event){
log('binding ' + event.type + ' with(ctrl+l) to <b>table</b> applied on <b>#' + event.target.id + '</b>');
event.stopPropagation();
event.preventDefault();
}
function unbindClick(){
$('table').unbind('click', clickHandler).unbind('keyup', 'ctrl+l', clickHandler);
}
function unbindKeyup(){
$('table').unbind('keyup', 'ctrl+l', clickHandler);
}
function log(msg){
$('#logger').html(msg);
}
</script>
</html>