Questions tagged [keypress]

Occurs when a key is pressed while the control has focus.

Occurs when a key is pressed while the control has focus.

This is the key press template primarily designed to illustrate keys and keystrokes on a computer keyboard.

With additional parameters, a single template can even illustrate a combination of multiple simultaneous keystrokes. A sequence of keystrokes, on the other hand, need to be demonstrated with separate templates.

2619 questions
0
votes
0 answers

Trigger Alt from KeyPress

I want to detect Alt, or Alt + some key, from within Form1_KeyPress. This is my code: private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (Control.ModifierKeys == Keys.Alt) { …
spunit
  • 523
  • 2
  • 6
  • 23
0
votes
0 answers

How do I make it so this code only executes once when I press the key

the way I have it now when I press the key it keeps doing the code until I press the key again but I want it to do the code once when I press the key void test() { bool active = true; int num = 0; while (active) { if (GetKeyState(VK_PRIOR)) { …
Lintee
  • 1
  • 1
0
votes
1 answer

Detect Keyboard presses in a cmd window

I am trying to detect the keyboard presses just when I am in the cmd window running a ROS2 node. I have already written this using pynput, but it detects all keys pressed even if I am in another window. import sys import os import signal import…
marpe
  • 185
  • 2
  • 9
0
votes
1 answer

How to make value scale up at same rate as user keypress in unity

I'm currently trying to make an AI move smoothly when going up and down and I'm struggling to find something or a way to replicate the way the player controlled Game Object move. When my code runs currently, the Enemy AI appears to jump up and down…
cope
  • 11
  • 6
0
votes
1 answer

Get the final text of a textbox on `keypress` if the click event is allowed to go through

I want to be able to prevent a user entering characters into a textbox based on what the text of the textbox would be if the character gets entered. The initial thought is to do something like this:
MSOACC
  • 3,074
  • 2
  • 29
  • 50
0
votes
0 answers

How to not try to trigger disabled buttons on pressing enter by default

I have a react app, and when I was pressing enter it was triggering a hidden button, rather than the button that was showed. So I set it to disabled if hidden. But the problem now is that "on enter" nothing happens when that button is disabled. I…
Kieran
  • 612
  • 6
  • 22
0
votes
2 answers

How do I stop a while loop when ANY keystroke is registered in c#

I've been searching around for an answer but all I can find are solutions for if a user inputs a specific key. I want ANY key that is pressed to halt the repeating message in the loop. So if no key is pressed, the loop's message keeps going. do { …
0
votes
0 answers

How to detect a keypress event inside a function? Nodejs

How can a keypress be detected only inside a function and not on all code? I have this code: async function sellFunction() { let i = 0; let handle = setInterval(function() { logUpdate("Hello" + i++) }, 100); …
skzao
  • 1
  • 3
0
votes
2 answers

Keypress event intercepted 40 times even though I press the key only once in Javascript

I want to intercept the event "keypress" with javascript through the following code: document.addEventListener("keypress", (e) => { if (e.key === "a") { console.log("You pressed the key a"); } } The code actually works. The problem…
nix86
  • 2,837
  • 11
  • 36
  • 69
0
votes
1 answer

How can I use the VB.NET Key press

I created a mouse position program that can be used to save your mouse position {X, Y} I realised that this is not going to be effective unless I implement a method where for example pressing "5" will save that position The only way i can save the…
motrix
  • 29
  • 6
0
votes
1 answer

Trigger a keypress inside a TinyMCE instance

I've been trying to programmatically trigger a keypress in an active editor with TinyMCE. So far, I've tried numerous combinations let ev = new KeyboardEvent('keydown', { code: '13', key: 'enter', }); tinymce.activeEditor.fire('keypress',…
user1320651
  • 808
  • 2
  • 15
  • 42
0
votes
1 answer

How to detect Ctrl+Alt+x in the keypress event handler of a VCL TMemo control?

I've created a Delphi VCL app with a single TMemo control, and this is the code I have. I use it to detect Ctrl+somekey. For example, when I press Ctrl+x, it pops up the alert ctrl and the Ctrl+x's effect (cut) was cancelled. function IsKeyDown(Key:…
Fajela Tajkiya
  • 629
  • 2
  • 10
0
votes
0 answers

Changing Sprite When You Press a key

I have a sprite sheet that I can change the little slimey's picture from but it only changes like the actual image I want to make them so when I press the right key it takes the pictures and gives it the one where it's facing right. I tried to…
Zwei
  • 1
  • 3
0
votes
1 answer

Find x-axis location to make an element move

I'm trying to make an element move backward on the X axis when the user presses "a". However, I don't know how to make it move farther every time the users presses that key :(. I'm new to JS document.addEventListener("keypress", function (e) { let…
Teodora
  • 3
  • 1
0
votes
1 answer

How to change value of integer on keyPress

I have a JLabel which has a string that has an integer, which starts at 0. I want it so that way, every time a key (like "w") is pressed, the integer goes up by 1. I have searched the web far and wide, but I have returned nothing (maybe because of…
LeninYT
  • 1
  • 3
1 2 3
99
100