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
0
votes
0 answers

Fill an object with text using keycodes (with the possibility for keyboard shortcuts)

Are there other ways to write text with keycodes apart from these two methods? However, the bad part by the following methods is that they cannot handle shortcuts like shift + a... 1. Method Use a json-object filled with keycodes and characters,…
yckart
  • 32,460
  • 9
  • 122
  • 129
0
votes
3 answers

event.keycode on Javascript

I'm working with a web page containing a form with a textarea element. I want to restrict the input values to only numbers, using JavaScript. One method I have found is to check the keyvalues when users are entering data: function checkForEnter()…
Leonidas
  • 21
  • 1
  • 4
0
votes
1 answer

Convert KeyEvent.VK_[value] to String

Given an integer which comes from KeyEvent.VK_[value], such as KeyEvent.VK_SPACE or KeyEVENT.VK_F3, I'd like to convert it to the String of the key. For example keyIntToString(KeyEvent.VK_SPACE) would return "Space" How can I do this? I've tried…
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
0
votes
3 answers

Waiting for JTextField "SPACE" event

I have a JPanel with a JTextField and I'd like to implement waitForTextFieldSpace. I think making a custom JTextField would be the most elegant solution, but I'm not entirely sure. public class MyPanel { JTextField textField; …
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
0
votes
2 answers

KeyEvent Constants in Java

I came across this code: private boolean right = true; public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if ((key == KeyEvent.VK_LEFT) && (!right)) { left =…
Nicholas
  • 679
  • 2
  • 11
  • 29
0
votes
1 answer

KeyPressed calling JInternalFrame returns NullException

I have a JInternalFrame and i want to call another JInternalFrame when i press F1 in a JTextField, however i'm getting NullPointerException. This is my code GUI: jLabel2.setText("ID:"); getContentPane().add(jLabel2); jLabel2.setBounds(10,…
Washu
  • 835
  • 1
  • 9
  • 20
0
votes
1 answer

How to use multiple javascript events in one HTML doc?

I have a page with 2 javascript events, one triggered from the mouse, the other from the keyboard. When I load the page I can get one or the other to work, but not both. If I press a key first that function will run, but then I cannot do the mouse…
B Rad C
  • 510
  • 2
  • 6
  • 18
0
votes
2 answers

How can I get the key names of VK constants?

For example, some magical function public String function(int key) {} so that function(KeyEvent.VK_A) would return "A" function(KeyEvent.VK_DOWN) would return "DOWN" function(KeyEvent.VK_COMMA) would return "COMMA"
user1778856
  • 641
  • 4
  • 10
  • 17
0
votes
2 answers

Richtextbox deletes selected text

I have the following code: private void richTextBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.N) { richTextBox1.Select(1, 3); } } When I press the N key , the selected text is…
Sumi
  • 127
  • 2
  • 10
0
votes
1 answer

i am getting partial output to the following code

Since im a real noob to programming , i was trying to work out this code and i m getting a partial output. The idea was to print the character typed on the applet and if alt or shift key is pressed, it must be displayed in the status bar. The…
0
votes
2 answers

How to send a adb event for long press a key

I am trying to do some auto testing and I need to trigger a long press of a key using adb command from my PC. For example, a long press home button would bring up the lates used apps. I found that key event #3 is for home key. But I could not…
Safecoder
  • 1,035
  • 2
  • 17
  • 32
0
votes
0 answers

Preventing keystroke from cascading to top level from JTable

I've created a JTable with a custom TableCellEditor that uses a number spinner. My problem is that you commit the cell change by pressing enter (among others like clicking elsewhere in the table), but pressing enter will also run the application.…
Siebe
  • 320
  • 1
  • 3
  • 11
0
votes
1 answer

How can I control which form is submitted when the user presses enter, based on which form the mouse is positioned over?

I have three forms on a page. Each form has a username and password fields, and a checkbox. Detecting when the user presses enter and to submit the appropriate form is not a problem: $("input[type='text'], input[type='password'],…
user717236
  • 4,959
  • 19
  • 66
  • 102
0
votes
4 answers

getting source of KeyEvent

i have two text fields(tf1 and tf2) on which in have used KeyEvent to get the typed characters. JTextField tf1 = new JTextField(10); JTextField tf2 = new JTextField(10); tf1.setFocusable(true); tf2.setFocusable(true); …
navyad
  • 3,752
  • 7
  • 47
  • 88
0
votes
2 answers

How to make a Swing JTextArea respond to KeyEvents?

I have a JTextArea component in my Swing code and I would like to add a handler/listener that is triggered anytime the user is typing (key events; key up, key down, etc.) text in the JTextArea. According to the JavaDocs above, I can add a…
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756