Questions tagged [keydown]

"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".

Filter by
Sorted by
Tagged with
0 votes
4 answers
60 views

Use 2 keycodes to return event

I'm 3 weeks into learning JS, and am working on a project to build a playable piano. When typing the letter c, it will play the note c. That part is working fine, but now I want the user to hold the ...
kolbykiernan's user avatar
0 votes
1 answer
35 views

How to detect and map many keys being pressed at once

I am using the keydown and keyup event to detect key presses. But when I press 2 or 3 or more keys and hold them down, most of the time it won't recognize any more keys pressed after, until I stop ...
MWRazer's user avatar
  • 15
1 vote
1 answer
23 views

How do I stop my activeElement.value modifications from modifying the activeElement and the following element?

I am creating a set of input boxes that accept 1 character each. Whenever I keydown a character, I want the document.activeElement.value to be set to the value of the event.key and then I want to ...
Kaelirk's user avatar
  • 11
1 vote
1 answer
74 views

How to change background on every button of virtual keyboard?

Can you help me with my virtual keyboard? I need to add keydown event with changing background into orange color on each button. in HTML I use buttons with classes .letter and .symbol. window....
Nadia Den's user avatar
0 votes
1 answer
33 views

How to make a <li> using keydown of enter and .appendChild in JS?

I have an input text field I'd like to create a in my when enter is pressed. I'm not sure where I went wrong in my code. Here's a snippet of the HTML I'm editing `<div class="day" id=&...
breanne1209's user avatar
0 votes
0 answers
31 views

How to make TreeviewItem unselected but focused when the user presses up/down arrow keys within wpf treeview

I have a treeview consists of 4 manuel treeviewItems labelled as shown below respectively. Lets assume that I have selected Item1.1 once. If I hover the mouse over the other treeviewItems, as you can ...
UGURENG's user avatar
  • 13
0 votes
0 answers
65 views

KeyDown event doesnt trigger with Shift. Other Keys Work

I´ve got multiple buttons that need to be accessed through KeyDown events in a Windows Form. I´ve set up some of them without any problems, but when setting the KeyCode to Keys.LShift it just doesn´t ...
thrieks's user avatar
1 vote
2 answers
358 views

How the Maui to get keydown events,select all text of entry ,remove entry undline

How could I use MAUI to create a keydown event? Also, we know there is no direct view for us to use keydown or keyup, but I have researched handler mappers in nativeview (Android) or using render, ...
simone's user avatar
  • 21
0 votes
0 answers
148 views

Using Javascript to simulate keyboard input into an <input> HTML element

Here is Javascript the code: function getKeyBoardEvent(c, eventName = "keydown") { return new KeyboardEvent(eventName, { altKey:false, bubbles: true, ...
ShamilS's user avatar
  • 1,452
2 votes
0 answers
17 views

How to set ctrl button active (simulate that it is pressed) when page loads in javascript?

I have embedded a google map iframe into an html document. I want when the user rotates/scrolls mousewheel up or down over the iframe, it should zoom in and out on the map respectively. But here, a ...
MS09's user avatar
  • 21
0 votes
1 answer
42 views

Is There a way to check if keydown inputs are pressed in a specified sequence?

I'm Trying to implement a cheat-code like function in my website where if a person enters a sequence(like right up left down(using arrow keys)), an element of the website changes. Currently, I've made ...
Musab Abdul Hameed Shah's user avatar
0 votes
1 answer
203 views

how do you create an event listener to listen for click and enter key at the same time?

how do you create an event listener to listen for click and enter key at the same time with little code? Is there a short method for this? In a perfect world i would imagine something like ...
DeBoer753's user avatar
0 votes
1 answer
29 views

From OnKeyDown Call OnKeyPress

for some reason in my environment (CAD) Keypress is not called. So I need to call it manually from overridding KeyDown event. How to convert KeyDown information to a char to pass to KeyPress Event and ...
andreat's user avatar
  • 297
-1 votes
1 answer
31 views

Limit keydown execution only to specific div

I want to limit execution with hit enter only to specific div, not on whole page so that this enter key not impact to divs outside this #targer-wrapper but code below with checking div length didn't ...
alench's user avatar
  • 67
2 votes
1 answer
57 views

HTML input: check if user input happened before or after existing value

I need to handle basic users to handle most of edge cases. I have an input which value is being parsed after typing. Right now I have problems when a user moves the cursor at the beginning of the ...
Sampgun's user avatar
  • 2,852
0 votes
0 answers
98 views

WebAPI `keydown` event behaves differently on mobile browers

I need to get the pressed "key" from the keydown event: const logEl = document.getElementById('log'); document.body.addEventListener('keydown', e => { logEl.innerText += `key: ${e....
goodUser's user avatar
  • 329
-3 votes
2 answers
182 views

Is it possible to have a key "Start" and then "Stop" a function?

I want to achieve the following: I press and release the C key, and the letter C is typed, as normal. But instead, I want to press and release the C key, and have ...
Willicious's user avatar
0 votes
1 answer
64 views

.NET WinForms KeyEventArgs.SuppressKeyPress: effect of setting it to True in the KeyUp event

The KeyEventArgs class in WinForms implements the Boolean SuppressKeyPress property. KeyEventArgs provides data for the KeyDown and KeyUp events. The SuppressKeyPress property can be set to True in a ...
TecMan's user avatar
  • 2,829
0 votes
0 answers
83 views

Trigger ESC to close AntD modal

My current code: https://codesandbox.io/s/basic-antd-4-24-8-forked-pxxe80?file=/demo.tsx I want to close the modal by triggering keydown. I tried triggering on the <p> and document, to no avail. ...
Minh Nghĩa's user avatar
-1 votes
1 answer
52 views

How to remove keydown eventlistener? [duplicate]

I have the following code that will run when an iframe webapplet is loaded in the current page. window.addEventListener("keydown", function(e) { if(["Backspace","Tab",&...
CapsaCool's user avatar
1 vote
2 answers
89 views

an issue with keyDown event in different browsers

so the thing is that 'keydown' event calls after the keyup event if multiple keys are pressed and released in particular order in chrome, but seems like there is no such issue in firefox browser for ...
Svygzhryr's user avatar
0 votes
0 answers
33 views

react location.replace error when triggered by keydown

React I'm developing a popup and I want to close it down with both a button and the esc keydown. However, even if I use the same function for both, some reason the window.location.replace() part ...
Jack's user avatar
  • 1
0 votes
1 answer
113 views

calling multiple functions in @keydown vue3 error

I have two functions which I'm trying to call with an inside input tag using @keydown="test(); numOnly();" and get the error TypeError: Cannot read properties of undefined (reading 'key') ...
Acs's user avatar
  • 3
0 votes
1 answer
109 views

JavaScript keydown event does not work when the focus is a gmail writing input

I'm trying to make a Chrome extension with JavaScript which triggers an action on key presses when I'm typing an email in gmail. I manage to make the extension, which performs a console log correctly ...
PedroPicateclas's user avatar
0 votes
1 answer
67 views

React keydown useeffect not working on page load

I'm trying to listen for keydown events and this code isnt working on initial page load. If i refresh, then make some code changes, and the page refreshes, it works just fine. Works when: Open page ...
UncleJerry23's user avatar
0 votes
1 answer
94 views

CGEventTapCreate detecting multiple keyboard inputs

I'm working on a macOS menubar app that locks any mouse events. What I'm trying to achieve is that after sending mouse events to the CGEventRef based callback, I cannot click anywhere (naturally) but ...
Ömürcan Cengiz's user avatar
0 votes
1 answer
95 views

Can a user exit a contenteditable with a key?

I currently have a content editable that allows users to change text within a span. I want to make it so that the content editable container closes after the user presses the Enter key. container....
Leblanc James's user avatar
0 votes
1 answer
120 views

Why when I press two keys simultaneously and stop pressing one, the other stops working?

I am working with keyboard events in Javascript. My goal is to be able to move images on a canvas with the keyboard arrows, but there is a problem: when I press two keys simultaneously and then ...
Johan Rodriguez's user avatar
0 votes
1 answer
34 views

Input fields with char count values (if i use keyup it show exactly but if i use keydow it show incorrect values )

all input fields with limited chars, am using with jquery function to get proper output if i use keyup it works fine but not applying to all popup wizard in my application if i use keydown it shows ...
thrinuu 's user avatar
0 votes
0 answers
53 views

Range slider getting stuck when using buttons/keydowns to move it

I have this range slider that is having some issues, I want the step of the slider to be 1 until it is over 36, in which I then want the step to be 3. It seems to be working okay besides during some ...
Wx_Trader's user avatar
0 votes
0 answers
37 views

Is the 'input' event always queued before knowing whether its handler will actually be called?

I have some code to be run: immediately after the input event handler if it's called when this handler would usually be called if it's not. I noticed that queuing a message with setTimeout in the ...
ghostinpeace's user avatar
2 votes
1 answer
660 views

How to catch keydown event inside child component

There is a component that catches keyDown event. It has a counter which is incremented by Arrow Right and decremented by Arrow Left. export default function App() { const [position, setPosition] = ...
Pepe's user avatar
  • 461
0 votes
0 answers
237 views

how to stop firing a keyDown event that are being called multiple times after one click

window.addEventListener('keydown', e => { if (renderBall) { if (e.key == 'ArrowLeft') { setBallPosition({ ...ballPosition, left: parseInt(...
Ansari iftekhar's user avatar
0 votes
1 answer
244 views

JS detect if key is held down longer than one second before keyup

I know there's Detecting duration of key-press using JavaScript but I don't want to know how to detect duration after user let go of the key but while it is still held down, as Alfredo Awesome ...
Lampe2020's user avatar
  • 147
1 vote
1 answer
723 views

React addEventListener duplicate listener

I am making a gallery app in React and I stucked 'cuz when I want to change img by key (left & right arrow) React/browser/JS? duplicates listener, as you can see: The code looks like this: const ...
lukaasz555's user avatar
1 vote
0 answers
29 views

I cannot get my KeyDown event to work in one project altough the exact same code works in another, older program I made (both on VS2022). Any ideas?

My original program was created in VS2019 but also works in VS2022. The original code in the first project exists on the ONLY form in the project. The new program was created in VS2022. The original ...
redski's user avatar
  • 11
0 votes
1 answer
41 views

Trying to removeEventListener but its not working. Javascript

I am trying to remove this event listener that I added and it doesn't remove. I'm not sure what I am doing wrong. Any thoughts is greatly appreciated? My code is below. headerElement.addEventListener('...
JakeMN's user avatar
  • 37
0 votes
2 answers
42 views

How do I make this key detector code work?

I am making a "hotkey" for my site but the code I am using is not working. How it is intended to work is when the user presses CTRL and ` it should display an alert with the message hi. But ...
Ultimate's user avatar
1 vote
2 answers
85 views

Please explain this MDN example

I'm learning javascript through MDN documentation. They have an example on the function topic which apparently I'm unable to understand. const textBox = document.querySelector("#textBox"); ...
user avatar
0 votes
1 answer
42 views

Logging happens when Shift+key is pressed

Maybe someone can guide me in the right direction. I am trying to make logging happen if the Shift+key is pressed and not happen if only the Shift is pressed. At the moment it works as expected, ...
Nat's user avatar
  • 5
0 votes
1 answer
160 views

How to send a GET request on "keydown" in react

I've been working with Spotify api on my music app project (nothing too complex). Now I've ran into a problem which I've tried solving to no avail. Allowing users to send GET request to the backend ...
owl Hld's user avatar
  • 23
0 votes
1 answer
418 views

using Function Keys on a windows form

The requirement is for a user to enter a number in a textbox and if they press F5 the code does something with the value in the textbox. I have set the form's this.KeyPreview = true; When user hits F5 ...
darthnoob's user avatar
1 vote
1 answer
342 views

React canvas keydown with no response when trying to move block to the right

I have been trying to create an animation so that i can control the block with my arrow key and spacebar on my keyboard, I have managed to get the jump working by changing the velocity y figures,...
tomtom's user avatar
  • 99
2 votes
1 answer
67 views

No response on keydown when using requestAnimationFrame in React.js

I have been trying to create a little animation on canvas using React.js. I expect the red block inside the canvas to go up and drop back down when I hit my spacebar by decreasing the velocity so that ...
tomtom's user avatar
  • 99
2 votes
1 answer
75 views

Undefined error when trying to read and change value from useState using keydown on React

I have been trying to create a little animation on canvas using React.js but having trouble interacting my Keydown function with my useState, for some reason, it wouldn't define my useState value, and ...
tomtom's user avatar
  • 99
0 votes
2 answers
250 views

WPF determine all keys released in textbox?

I wanted to make user to customise the shortcut keys, so I'm using a textbox to get the key input. The expected state should be to save the key when pressed, and show KeyGesture string when released. ...
tp1415926535's user avatar
2 votes
1 answer
284 views

JS Always check keydown

I'm building a 3D FPS game with Three.js. When I use a full auto weapon, I want it to continuously fire from the second you hold down the "f" key. But instead JS detects the first keydown ...
ProOfficial's user avatar
0 votes
2 answers
947 views

React/Next.js Keydown Event Listener Not Triggering Correctly

I'm trying to build an Image Gallery Lightroom component within React/Next.js, and I've got everything working so far in that clicking on the gallery images opens a modal in a react portal. I've got a ...
Josh Walter's user avatar
0 votes
1 answer
609 views

Detect/override controller "Home" button press android

I have an android application that is meant to be used with a game controller connected to the android device. Most game controllers have a center 'home' button that I would like to use to pause the ...
alexward1230's user avatar
1 vote
1 answer
491 views

State is <empty string> when function is called on key event

In React, I have a number of buttons (imagine a PIN layout with numbers) that update the state on click. I also added an event listener to the document so pressing keys on the keyboard updates the pin ...
Shahriar's user avatar
  • 1,982

1
2 3 4 5
29