aspose file tools*
The moose likes Applets and the fly likes arrow keys in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "arrow keys in java?" Watch "arrow keys in java?" New topic
Author

arrow keys in java?

ajay smith
Greenhorn

Joined: Feb 02, 2013
Posts: 9
So I'm trying to build a small game and I have all the logic down, but how does the program know if a key is pressed down? For example:

if( left arrow key is pressed down)
{ move thing left }
else if(right arrow key is pressed down)
{ move thing right }

and so on. I already know how to move the thing, but how do you make java respond to keys being pressed down?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Swing? Console? HTML? Some context is needed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ajay smith
Greenhorn

Joined: Feb 02, 2013
Posts: 9
It's in an applet using AWT, trying to make something move
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

ajay smith wrote:It's in an applet using AWT

AWT has been superseded by Swing more than a decade ago. I stronly recommend that you convert this Applet to a JApplet, and replace the AWT components with their Swing equivalents. You can then use Key Bindings for your purpose.


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: arrow keys in java?
 
Similar Threads
In Game Programming, how do I do frame animations?
Multiple Key Press
Windows Keys and Java Application
IntelliJ IDEA arrow navigation does not work with numeric keypad arrow keys
Need some help with key bindings