"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
-1
votes
1 answer
Javascript keydown event twice to cancel
My intention is to make div when keydown, and remove div when the same key is pressed again.
This is my code.
let keydown = false;
document.addEventListener('keydown', function(e) {
if (e.code === 'Space') {
if (!keydown) {
keydown =…

Jessie Park
- 31
- 3
-1
votes
1 answer
How to not allow two keys to be pressed in a row in JavaScript?
Im making a snake game and need some code to not allow the same key to be pressed in a row. So for example if 'w' is pressed, it wont be able to be pressed again until another key is pressed.
Anyone now the simplest way to achieve this? Thanks

Kas
- 111
- 3
- 10
-1
votes
1 answer
Scrolling Text in DIV on Keydown
I want to create a scroll effect on the div such that when the SPACE key is pressed, the first span moves up out of visibility and the span become visible.
HTML
Lorem ipsum dolor sit amet consectetur,…

humleAfriqan
- 59
- 10
-1
votes
3 answers
How to use onkeyup and onkeydown for an input tag?
I have an input field and i want to do some calculations depending upon keyup and keydown.
I tried using onkeyup and onkeydown functions, but when i press a key from the keyboard, it prints both "keyup" as well as "keydown" in the console. Is there…

Rhugveda Desai
- 74
- 2
- 11
-1
votes
2 answers
keydown in objective-C
[UPDATED AFTER FIRST AWNSER]
I have tried to find a way to use and implement the keyDown option in Objective C. But when I try it, it always fails...
Can anyone give me an example of how this is done. I understand Objective C good and a full…

Muttur
- 31
- 2
- 4
-1
votes
1 answer
How to leave WPF UserControl somewhere inside UserControl?
I'm making a UC (UserControl) in WPF. I have some text boxes in the UC. I want to leave the UC when the user pressed "Return key" on one of them. I want return key to treating like Tab key in the main window. How can I implement it?

Shaho
- 182
- 2
- 14
-1
votes
2 answers
How to stop renderer keydown event to pass to other components in Angular?
I am trying to listen for keydown for particular key in Angular 6. I am able to get the keydown event but it also passes to other services/componenets in my code which are listening for keydown.
I read that this concept is called bubbling and I…

pranavj95
- 151
- 9
-1
votes
2 answers
How to Close a Modal / Dialog Box Using the ESC Key?
Hi so I am using these Modal / dialog boxes on my site. I am using code from W3-Schools which is jQuery if I'm not mistaken. They work fine and I was able to get them to close by clicking outside the box, but I am having trouble with having them…

Sam Max
- 3
- 1
- 2
-1
votes
1 answer
Improve javascript function to not allow key holding
I created a function which checks if forbidden characters were typed and removes them, everything works fine until user starts holding key. Could someone help to improve?
function tooltip(object, type) {
var id = object.getAttribute('id');
var…

Grufas
- 1,350
- 4
- 21
- 33
-1
votes
1 answer
Simple javascript / jquery "on [Escape]" action - how to do it?
I've been mired in documents explaining javascript keydown events for days - and still can't find out how to do this!
What I want:
$( 'element' ).on( blur mouseleave ESCAPE, function( event ) {
do stuff;
}
It's trivial, right? I realise I might…

cherryaustin
- 456
- 4
- 9
-1
votes
2 answers
C# Compare the Key Pressed on the Keyboard
I have a textbox and a button.I'm saving the value(keyboard key) entered in the TextBox.I need to give a message when I press the right keyboard key.
private void btn_Click(object sender, EventArgs e)
{
Properties.Settings.Default.text1 =…

H.Marcus
- 31
- 7
-1
votes
1 answer
Playing audio with keydown
So I am not able to make this code work. What should happen is, an audio file should play whenever I press a key that is corresponding to the audio. But for some reason whenever I press the key, nothing happens. Please…

Martin Zahariev
- 697
- 1
- 7
- 6
-1
votes
1 answer
Method cannot handle event "KeyDown because they do not have a compatible signature"
So I'm trying to make a program which detects when I key is pressed down and assigns the value of said to a variable and then outputs it in a message box, however I cannot do this because of the follow error:
Method 'Main_KeyDown' cannot handle…

ADAMPOKE111
- 5
- 7
-1
votes
1 answer
trigger event with spacebar keydown for set duration
I have an animation that should start on keydown for a set duration (3s or so).
Wondering if I can bind the animation function to jquery keydown but how can I add the duration to that or if there is another jquery plugin that can handle this?
The…

njpatten
- 165
- 1
- 3
- 15
-1
votes
2 answers
Force keyup after keydown
I have 5 inputs, everyone of them will wait for a letter. Once one is filled with a letter I have to automatically jump to the next input.
Problem is that, if I capture only keyup this makes me jump correctly, but doesn't let me to write "quickly".…

R01010010
- 5,670
- 11
- 47
- 77