Best way for using keypress to move images/character

I usually use the keyevent to set the character to a certain image whenever it is pressed. On someone’s YouTube channel, I noticed whenever a key was pressed it would retrun the Boolean left, right, up, down, etc… For adding gravity, gliding and other movements, what way would be easier or make things simpler. What do you do to get the image to switch ??? First time embedding a youtube video, sorry if it doesn’t work somehow.

MmB9b5njVbA

I used YouTube Icon but this is the plain embed code

Or use URL :

[youtube]The numbers and letters after the /watch?v= goes here.[/youtube] No need to use the embed button, just copy that part of the link directly.

Here use this! :smiley:

You can easily incorporate keyboardhandler class with swing/awt or whatever you are using.