DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 7 of 7

Thread: Key Codes....

  1. #1
    Join Date
    Feb 2004
    Posts
    34

    Key Codes....

    Hello ,

    I hae been programming for a couple months now and I have been using the depracated way to get Key inputs..
    ie. public boolean keyDown(Event e , int key)... and they have worked, up till now. For an assignment at school I have to use the public void keyPressed(KeyEvent event) method to get KeyBoard inputs. My question was, if I use event.getKeyCode() can I compare that directly to key Codes i know already? If I use event.getKeyCode() and I pressed te spacebar , will it give me an integer of 32 like the depracated one? If not, does anyone know where I can find a list of all the keys on a keyboard and their codes?

    Thanks in Advance.
    www.saterasoft.cjb.net

    Come and play the games.....

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    look more closely at the KeyEvent API

    you will see things like:

    KeyEvent.VK_SPACE

    as a public final constant integer, so you dont compare literal values..

    if(evt.getKeyCode() == KeyEvent.VK_SPACE){
    //they pressed the space bar
    }
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    Feb 2004
    Posts
    808
    as always in things like this, the api is your best option:

    http://java.sun.com/j2se/1.3/docs/ap.../KeyEvent.html
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  4. #4
    Join Date
    Feb 2004
    Posts
    34
    Thank You cjard , I hadn't even thought of looking in the API.
    www.saterasoft.cjb.net

    Come and play the games.....

  5. #5
    Join Date
    Feb 2004
    Posts
    808
    how do you program, without using the API?
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  6. #6
    Join Date
    Feb 2004
    Posts
    34
    Shh... its a secret,

    Sorry bout that , I meant the Documentation not the API itself.
    www.saterasoft.cjb.net

    Come and play the games.....

  7. #7
    Join Date
    Mar 2004
    Posts
    635
    Without looking at the API, I'd never get anything done.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links