Questions tagged [keyevent]

An event that is triggered when a key is pressed,released or remains pressed on a keyboard input device.

A KeyEvent is an event that is triggered when a key is pressed, released or remains pressed on a keyboard input device. The event can contain:

  • info about particular key that was pressed/released
  • how long the key was pressed
  • whether any modifier keys were also pressed (such as Ctrl or Alt).
  • type of event - press, release, other (for example character was typed, regardless whether key was pressed or released)

Some platforms/keyboards may generate auto-repeat key events - same character is typed repeatedly while key remain pressed

1258 questions
-1
votes
1 answer

How do I print the whole string in KeyListener?

After storing the string into nick I want to print the string, but when I print string it only prints the last character, not whole string. How do I print the whole string?
-1
votes
1 answer

Why JavaFX stucks when running a process?

I am building an application using JavaFX. Application does some CRUD operations with the MySQL Database. So currently, I have 2 functions. User Registration. Email Validation (Check if email already exists in the database). User registration is…
Tech Guy
  • 55
  • 7
-1
votes
1 answer

How to set KeyEvent to KeyCode.BACK_SAPCE in JavaFx?

I'm trying to set KeyEvent KeyCode to KeyCode.BACK_SAPCE if entered value is not a digit. But I'm not able to achieve it public void textFieldKeyReleased(KeyEvent e) { if (!e.getCode().isDigitKey()) { textField.setText(""); //manually…
Swapnil
  • 115
  • 1
  • 12
-1
votes
1 answer

KeyListener not detecting keypress

I have a game built and I want to be able to pause the game when the P Key is pressed. However, whilst the game is running the KeyListener does not seem to be detecting the P Key has been pressed. Is my code correct? Have I placed addKeyListener in…
Alice
  • 588
  • 1
  • 8
  • 25
-1
votes
2 answers

Managing focus with label and buttons - Display key press in label

When I use the term inactive node below, what I mean is something that should not be able to interact with the user. I built a general login screen similar to this: One label, the typing label above the number keys takes both button input as well…
Jack J
  • 1,514
  • 3
  • 20
  • 28
-1
votes
1 answer

Cannot resolve the "e" in e.getKeyCode();

im trying to implement a Key Event, but eclipse can't resolve the "e" in e.getKeyCode(); What am I missing here? Error
-1
votes
1 answer

Simultaneous/Combined MouseListener & KeyListener, MouseEvent & KeyEvent Java

I want to know how work Simultaneously a MouseEvent & KeyEvent. Suppose an JFrame, JPanel. I want to know how work with an Event when certain MouseEvent & KeyEvent example: addKeyListener(new KeyAdapter() { @Override public void keyReleased(…
user7339033
-1
votes
1 answer

JAVA linux KeyListener seems not working

i'm working on JAVA snake game and it seems my KeyListener not working for some reason. I tried to look for answers but i couldnt find anything helpful. I'm beginner in JAVA so i dont know if i'm using the keylistener properly. I got no output at…
-1
votes
1 answer

handle ctrl+v in a multiline textbox c#

I have a multiline textbox, and I'm trying to implement shortcut keys for select all, copy, paste, etc. (multiline seems to disable some of the native shortcuts). I have this code, inside a switch for KeyCode if on Control KeyDown. case Keys.A: …
Poootaatoooo
  • 316
  • 1
  • 10
-1
votes
3 answers

Android: Overriding the power button in a Fragment

I'm working on a thing where I need to override the power button in a Fragment when pressed. I did this successfully, however, the screen turns off when the power button is pressed. I did a quick search and came across a few posts like this, this,…
user3445871
-1
votes
1 answer

adding events to random buttons of the keyboard

Hello guys i really need your help . I want to make some program in javafx so i need to add listener to random generated button on the keyboard. For example : i don't want to add some action if user type enter but i want to add action to some random…
Milos
  • 87
  • 1
  • 9
-1
votes
1 answer

How to remove action event after key pressed in a text field?

I have a text field and mapped the enter key with an action to that text field. After enter key press, How can I remove that key event for press enter key in the text field?
-1
votes
2 answers

How to get keyEvent to work in Java?

I'm completely new at programming Java. I can't get my keyEvents to wont work. I need this for a little game I'm making. Here is my code: package markusrytter.pingpong; import java.awt.Graphics; import java.awt.Graphics2D; import…
markus rytter
  • 140
  • 1
  • 3
  • 13
-1
votes
2 answers

Check Keyboard Input Winforms

I was wondering if instead of doing this protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.A) Console.WriteLine("The A key is down."); } I could set up a bool method and do this: if(KeyDown(Keys.A)) // do…
user6630825
-1
votes
3 answers

Making a String from KeyTyped in Java

I must make a nickname, and I do everything, using KeyListener. I want to write nickname using keyTyped, but I have no idea, how to save each letter. For exaple: keyTyped(KeyEvent e){ char key = e.getKeyChar(); nick = new…
klucyszy
  • 152
  • 6