GlobalEventHandlers.onkeydown
onkeydown
속성은 현재 요소(element)의 onKeyDown
이벤트 핸들러 코드를 돌려줍니다
element.onkeydown = event handling code
Example
This example logs the KeyboardEvent.code
(en-US) value whenever you press down a key inside the <input>
element.
HTML
<input>
<p id="log"></p>
JavaScript
const input = document.querySelector('input');
const log = document.getElementById('log');
input.onkeydown = logKey;
function logKey(e) {
log.textContent += ` ${e.code}`;
}
Result
명세
명세 | 상태 | 비고 |
---|---|---|
HTML Living Standard The definition of 'onkeydown' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser