mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-18 06:50:23 +00:00
46 lines
No EOL
2 KiB
HTML
46 lines
No EOL
2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang='en'><head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1"><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
|
|
<div data-role="page">
|
|
<div data-role="header">
|
|
<h1>event.which</h1>
|
|
|
|
</div>
|
|
<div data-role="content" data-theme="c" id="event.which1">
|
|
<h2 class="jq-clearfix roundTop section-title">
|
|
<span class="name">event.which</span> <span class="returns">Returns: <a class="return" href="http://docs.jquery.com/Types#String">String</a></span>
|
|
</h2>
|
|
<div class=" entry-details">
|
|
<p class="desc"><strong>Description: </strong> For key or button events, this attribute indicates the specific button or key that was pressed. </p>
|
|
<ul class="signatures"><li class="signature" id="event.which"><h4 class="name">
|
|
<span class="versionAdded">version added: <a href="/category/version/1.1.3/">1.1.3</a></span>event.which</h4></li></ul>
|
|
<div class="longdesc"><p><code>event.which</code> normalizes <code>event.keyCode</code> and <code>event.charCode</code>. It is recommended to watch <code>event.which</code> for keyboard key input. For more detail, read about <a href="https://developer.mozilla.org/en/DOM/event.charCode#Notes">event.charCode on the MDC</a>. </p></div>
|
|
<h3>Example:</h3>
|
|
<div id="entry-examples" class="entry-examples"><div id="example-0">
|
|
<h4><span class="desc">Log what key was depressed.</span></h4>
|
|
<pre><code class="example demo-code"><!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="http://code.jquery.com/jquery-latest.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<input id="whichkey" value="type something">
|
|
<div id="log"></div>
|
|
<script>$('#whichkey').bind('keydown',function(e){
|
|
$('#log').html(e.type + ': ' + e.which );
|
|
}); </script>
|
|
</body>
|
|
</html></code></pre>
|
|
<h4>Demo:</h4>
|
|
<div class="demo code-demo"></div>
|
|
<h4>Result:</h4>
|
|
<pre><code class="results">"keydown" 74 </code></pre>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body></html> |