"keydown" is an event used in writing software that is triggered when a key on the keyboard is being pressed. It usually precedes the event "keyup".
Questions tagged [keydown]
1434 questions
221
votes
19 answers
How to detect if multiple keys are pressed at once using JavaScript?
I'm trying to develop a JavaScript game engine and I've came across this problem:
When I press SPACE the character jumps.
When I press → the character moves right.
The problem is that when I'm pressing right and then press space, the…

XCS
- 27,244
- 26
- 101
- 151
170
votes
7 answers
onKeyDown event not working on divs in React
I want to use a keyDown event on a div in React. I do:
componentWillMount() {
document.addEventListener("keydown", this.onKeyPressed.bind(this));
}
componentWillUnmount() {
document.removeEventListener("keydown",…

Michael
- 6,823
- 11
- 54
- 84
89
votes
10 answers
Up, Down, Left and Right arrow keys do not trigger KeyDown event
I am building an application where all the key input must be handled by the windows itself.
I set tabstop to false for each control witch could grab the focus except a panel (but I don't know if it has effect).
I set KeyPreview to true and I am…

Martin Delille
- 11,360
- 15
- 65
- 132
70
votes
6 answers
How to decode character pressed from jQuery's keydown()'s event handler
I need to figure out which character was typed into a text field from within the handler that is called by jQuery's keydown function. key.which gives me only the keycode, but I need to figure out which ASCII character key represents. How do I do…

Chetan
- 46,743
- 31
- 106
- 145
64
votes
4 answers
OS X: Detect system-wide keyDown events?
I'm working on a typing-tutor application for Mac OS X that needs to have keystrokes forwarded to it, even when the application is not in focus.
Is there a way to have the system forward keystrokes to the app, possibly through…

Chris Ladd
- 2,795
- 1
- 29
- 22
62
votes
2 answers
tabindex in CSS
Is it possible to control tabindex with CSS and if yes, which browsers support it and on which elements?
EDIT
I should say, my goal is to catch keydown events on a div. I saw this page http://www.quirksmode.org/js/events/keys.html# that tests…

Boris Hamanov
- 3,085
- 9
- 35
- 58
54
votes
11 answers
keypress, ctrl+c (or some combo like that)
I'm trying to create shortcuts on the website I'm making. I know I can do it this way:
if(e.which == 17) isCtrl=true;
if(e.which == 83 && isCtrl == true) {
alert('CTRL+S COMBO WAS PRESSED!')
//run code for CTRL+S -- ie, save!
…

android.nick
- 11,069
- 23
- 77
- 112
50
votes
3 answers
jQuery key code for command key
I have read jQuery Event Keypress: Which key was pressed? and How can i check if key is pressed during click event with jquery?
However my question is if you can get the same key event for all browsers? Currently I know that Firefox gives the…

Craig
- 3,043
- 8
- 24
- 25
49
votes
3 answers
What's the theory behind jQuery keypress, keydown, keyup black magic (on Macs)?
I am confused about the various behaviors of keypress, keydown, and keyup. It seems that I have missed an important piece of documentation, one that explains the subtleties and nuances of this trio. Could someone help me to figure out which document…

SaganRitual
- 3,143
- 2
- 24
- 40
48
votes
14 answers
How can I capture KeyDown event on a WPF Page or UserControl object?
I have a Page with a UserControl on it. If the user presses Esc while anywhere on Page I want to handle.
I thought this would be as easy as hooking up the PreviewKeyDown event, testing for the Esc key, and then handling it. However, when I placed…

Sailing Judo
- 11,083
- 20
- 66
- 97
45
votes
3 answers
How to detect keyboard events in SwiftUI on macOS?
How can I detect keyboard events in a SwiftUI view on macOS?
I want to be able to use key strokes to control items on a particular screen but it's not clear how I detect keyboard events, which is usually done by overriding the keyDown(_ event:…

Duncan Groenewald
- 8,496
- 6
- 41
- 76
45
votes
7 answers
Python method for reading keypress?
I'm new to Python, and I just made a game and a menu in Python.
Question is, that using (raw_)input() requires me to press enter after every keypress, I'd like to make it so that pressing down-arrow will instantly select the next menu item, or move…
user1632861
42
votes
9 answers
jQuery - keydown() on div not working in Firefox
I have the following example code, which should pop up an alert when the div is in focus and a key is pressed. This does what I expect in IE 7, but not in Firefox 3.5.5. What am I doing wrong?
JS test