blob: d5f598104a72479c5ece5ceced2d224a2a89a97f (
plain)
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
|
---
title: GlobalEventHandlers.onkeydown
slug: Web/API/GlobalEventHandlers/onkeydown
tags:
- API
- HTML DOM
- NeedsContent
- NeedsExample
translation_of: Web/API/GlobalEventHandlers/onkeydown
---
<div>{{ApiRef("HTML DOM")}}</div>
<p><code><strong>onkeydown</strong></code> 속성은 현재 요소(element)의 <code>onKeyDown</code> 이벤트 핸들러 코드를 돌려줍니다</p>
<pre class="syntaxbox">element.onkeydown = <var>event handling code</var></pre>
<h2 id="Example">Example</h2>
<p>This example logs the {{domxref("KeyboardEvent.code")}} value whenever you press down a key inside the {{HtmlElement("input")}} element.</p>
<h3 id="HTML">HTML</h3>
<pre><code><input>
<p id="log"></p></code></pre>
<h3 id="JavaScript">JavaScript</h3>
<pre><code>const input = document.querySelector('input');
const log = document.getElementById('log');
input.onkeydown = logKey;
function logKey(e) {
log.textContent += ` ${e.code}`;
}</code></pre>
<h3 id="Result">Result</h3>
<p>{{EmbedLiveSample("Example")}}</p>
<h2 id="명세">명세</h2>
<table class="spectable standard-table">
<tbody>
<tr>
<th scope="col">명세</th>
<th scope="col">상태</th>
<th scope="col">비고</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG','webappapis.html#handler-onkeydown','onkeydown')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="브라우저_호환성">브라우저 호환성</h2>
<p>{{Compat("api.GlobalEventHandlers.onkeydown")}}</p>
|