forked from bitovi/jquerypp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey.html
More file actions
35 lines (34 loc) · 913 Bytes
/
key.html
File metadata and controls
35 lines (34 loc) · 913 Bytes
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>jQuery Event Key</title>
<style type='text/css'>
body {font-family: verdana}
</style>
</head>
<body>
<div id='demo-html'>
<label for='key'>Type in input:</label><input id='key' />
<div>Keydown:<span id='keydown'></span></div>
<div>Keypress:<span id='keypress'></span></div>
<div>Keyup:<span id='keyup'></span></div>
</div>
<script type='text/javascript'
src='../../../steal/steal.js'>
</script>
<script id="demo-source" type='text/javascript'>
steal('jquery/event/key').then(function(){
var readable = {
"\r" : "\\r",
"\b" : "\\b",
"\t" : "\\t"
};
$('#key').on('keydown keypress keyup', function(ev){
var key = ev.keyName();
$("#"+ev.type).html(readable[key] || key)
});
});
</script>
</body>
</html>