Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  KeyListener Limiting to Alphanumeric  (Read 1105 times)
0 Members and 2 Guests are viewing this topic.
Offline neoskunk

Full Member
**

Posts: 157



« on: 2010-07-11 21:25:02 »

I'm trying to create a keylistener that will only allow alphanumeric input.

I have done this before but cannot remember how. 

for some reason getKeyCode() continues to give me 0 regardless of what key is pressed.  is this normal?  I feel like in the past all i did was use an if statement something like:

1  
2  
if(e.getKeyCode() >= KeyEvent.VK_A && e.getKeyCode() >= KeyEvent.VK_Z)
do something


any ideas?
Offline neoskunk

Full Member
**

Posts: 157



« Reply #1 on: 2010-07-11 23:37:21 »

my mistake.  i had all the code in the keyTyped method.  should have been in the keyPressed method.
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.092 seconds with 19 queries.