GlobalEventHandlers.onkeydown

onkeydown 속성은 현재 요소(element)의 onKeyDown 이벤트 핸들러 코드를 돌려줍니다

element.onkeydown = event handling code

Example

This example logs the KeyboardEvent.code 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  

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onkeydownChrome Full support YesEdge Full support YesFirefox Full support YesIE ? Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown