Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

JavaScript Detect Keyboard current press using EventListener "keydown"

NotificationsYou must be signed in to change notification settings

nielsoffice/JSDetectKeyboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation


JavaScript Detect Keyboard current press using EventListener "keydown"
Reference:
https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event

document.addEventListener('keydown',function(e){// Detect which keyboard are currently press// Read the keyboard property { isTrusted: true, key: 'enter', code: 'keyEnter' }console.log(e);// access property via dot notation JS ex. e.keyconsole.log(e.key);// Usage:if(e.key==='Escape'){console.log(e.key);// do something! ...}});


Also EventListener "Keyup"
Reference:
https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event

// JavaScript Event https://developer.mozilla.org/en-US/docs/Web/Events

About

JavaScript Detect Keyboard current press using EventListener "keydown"

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp