[Функция] event.which
Раздел "Events"
Метод позволяет опередить тип нажатой клавиши или кнопки.
Пример:
"jQuery"
$('#whichkey').bind('keydown',function(e){
$('#log').html(e.type + ': ' + e.which );
});
"HTML"
<input id="whichkey" value="type something">
<div id="log" style="border:1px solid grey;height:100px;">
</div>
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="http://test-drupal.ru/themes/slyweb/css/jqueryiframe.css"
rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#whichkey').bind('keydown',function(e){
$('#log').html(e.type + ': ' + e.which );
});
});
</script>
</head>
<body class="iframe">
<input id="whichkey" value="type something">
<div id="log" style="border:1px solid grey;height:100px;">
</div>
</body>
</html>
<style>
</style>
Версия jQuery 1.4.2
Документ создан 2010-08-21