Results 1 to 3 of 3
- 07-15-2011, 08:51 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 10
- Rep Power
- 0
Key press not registering as ENTER
I have the following code:
No matter what I do, ENTER (either on the numeric keypad or the standard one) is not registering as ENTER... Very odd, I think.Java Code:optionWidth.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { super.keyTyped(e); if (e.getKeyCode()==KeyEvent.VK_ENTER) { System.out.println("Pressed ENTER"); } else { System.out.println("Key was NOT enter"); } } });
Am I just missing something here?
-Jason
- 07-15-2011, 09:21 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Read the API for KeyEvent's keyCode method, it states
Use keyPressed to get the keyCode.For KEY_TYPED events, the keyCode is VK_UNDEFINED
- 07-15-2011, 09:43 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
Press enter to continue (Jpanel)
By david522 in forum New To JavaReplies: 10Last Post: 05-22-2011, 03:40 PM -
Command not registering.
By Kuetsum in forum New To JavaReplies: 3Last Post: 01-18-2011, 07:19 AM -
Registering problem
By trini32 in forum New To JavaReplies: 1Last Post: 06-25-2009, 04:35 AM -
Reading Char without needing to press enter
By x0psci in forum New To JavaReplies: 0Last Post: 11-23-2007, 04:28 PM -
Press any key to continue/press enter
By JT4NK3D in forum New To JavaReplies: 1Last Post: 11-17-2007, 09:27 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks