"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
38
votes
7 answers
Changing the keypress
In an input box or contenteditable=true div, how can I modify a keypress for the letter "a" to return a keybress for the letter "b"? I.e., every time you type the letter "a" in the div, the output is actually the letter "b".
I'm not that concerned…

maxedison
- 17,243
- 14
- 67
- 114
37
votes
5 answers
jQuery .keypress & .keydown .which
Ok so what is the difference in .keypress and .keydown/.keyup? At present I am using .keydown which returns a .which value of 38 for my key, now if i change it to .keypress it returns a value of 109 for that same key. What is the difference and why…

ChrisMJ
- 1,620
- 4
- 21
- 27
35
votes
2 answers
IOS Bluetooth Keyboard - Inputs - Tab Event
Background:
I have a textarea. I capture the Tab key event when the user is typing, and I insert a Tab character (\t) and prevent the browser from focusing on the next input.
This works without issue on Mac and PC, on all browsers.
Problem:
When…

Tim Withers
- 12,072
- 5
- 43
- 67
30
votes
4 answers
Simulate pressing tab key with jQuery
I have some textboxes on a .net-page and want to achieve the following with jQuery: if the user presses return, the program should behave "as if" he had used the tab key, thus, selecting the next element. I tried the following code (and some…

AGuyCalledGerald
- 7,882
- 17
- 73
- 120
30
votes
4 answers
How do I capture Keys.F1 regardless of the focused control on a form?
I used KeyDown event and some simple code like if (e.KeyCode == Keys.F1) to capture F1 is pressed on a form BUT if there are some text boxes on the form or if there are some spreadsheets with Dock Fill on the form then the code above gets useless…

Bohn
- 26,091
- 61
- 167
- 254
29
votes
5 answers
C#: How to make pressing enter in a text box trigger a button, yet still allow shortcuts such as "Ctrl+A" to get through?
Sorry for the long title, but I couldn't think of another way to put it.
I have this:
private void textBoxToSubmit_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
…

Jonathan Chan
- 2,355
- 3
- 25
- 38
28
votes
6 answers
KeyboardEvent in Chrome, keyCode is 0
I am trying to set keyCode on dispatched event object .
On button click, event is raised on textbox control to simulating keydown event. Event is raised successfully, but keyCode is 0. I need to send event object with correct keyCode to…

Andrija
- 14,037
- 18
- 60
- 87
28
votes
9 answers
How to use multiple modifier keys in C#
I am using a keydown event to detect keys pressed and have several key combinations for various operations.
if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control && e.Modifiers == Keys.Shift)
{
//Do work
}
else if (e.KeyCode == Keys.V &&…

jsmith
- 7,198
- 6
- 42
- 59
27
votes
4 answers
C# trying to capture the KeyDown event on a form
I am creating a small game, the game is printed onto a panel on a windows form. Now i want to capture the keydown event to see if its the arrow keys that has been pressed, the problem however is that i can't seem to capture it.
Let me explain, on…

Patrick
- 5,442
- 9
- 53
- 104
25
votes
7 answers
DataGridView keydown event not working in C#
DataGridView keydown event is not working when I am editing text inside a cell.
I am assigning shortcut Alt+S to save the data, it works when cell is not in edit mode, but if it is in edit mode below code is not working
private void…

Javed Akram
- 15,024
- 26
- 81
- 118
25
votes
6 answers
Detecting "value" of input text field after a keydown event in the text field?
My site has an input box, which has a onkeydown event that merely alerts the value of the input box.
Unfortunately the value of the input does not include the changes due to the key being pressed.
For example for this input box:

rawrrrrrrrr
- 3,647
- 7
- 28
- 33
22
votes
5 answers
Get Char from Key
I am coding a custom text editor, and I use KeyDown and KeyUp events. That events gets a KeyEventArgs from parameters where a "Key" instance is included.
How I can transform that "Key" to a real char?
Using Key.ToString() with a "." I get a…

Jesús Galindo
- 471
- 1
- 5
- 11
21
votes
6 answers
Cancel the keydown in HTML
How can I cancel the keydown of a specific key on the keyboard, for example(space, enter and arrows) in an HTML page.

Jack
- 213
- 1
- 2
- 4
19
votes
2 answers
Cocoa: Key down event on NSView not firing
I have made a custom NSView and have implemented the keyDown: method. However, when I press keys the method is never called. Do I have to register to receive those events? fyi, I am making a document based application and can handle this code…

mtmurdock
- 12,756
- 21
- 65
- 108
18
votes
3 answers
Javascript, key press value is always one character behind the latest?
If I type 'St', by the time I press the t, if I output the input of textfield.value in the onkeypress/onkeydown functions, I only get 'S'.
Why is this? How do I get rid of this lag?

Tom
- 215
- 1
- 2
- 5