Thread [solved] Tastenevents mit Javascript behandlen (16 answers)
Opened by moritz at 2010-05-02 11:35

GwenDragon
 2010-05-03 09:59
#136676 #136676
User since
2005-01-17
14544 Artikel
Admin1
[Homepage]
user image
geht auch so mit Firefox 3.6:
Code (html): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="de" xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<meta http-equiv="content-type" content="text/html; charset=us-ascii" />
<script src="jquery-1.3.2.min.js" type="text/javascript">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
    $('html').keyup(function(e) {
        var code = e.keyCode || e.which;
        alert(code);
    });
});
//]]>
</script>
<title></title>
</head>
<body>
<p>Das ist ein Text.</p>
</body>
</html>


Wenn body nicht will, dann eben den Event an das Element html binden.

//EDIT: s/keydown/keyup/ in code
Last edited: 2010-05-03 10:02:33 +0200 (CEST)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread [solved] Tastenevents mit Javascript behandlen