Results 1 to 4 of 4
  1. #1
    Shadowstrike is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default Handling input - multiple keys pressed

    Hey,

    at the moment I'm working on a little Game-Framework for Processing (Processing is a small graphics-orientated language based on java). My first problem is handling kayboard input: the given functions keyPressed() and keyReleased() do only give information about the last key that was pressed. so now i have to write my own functions based on the java-API. i had the idea to use the keyListener-functions but they only can handle a single input, just like the processing functions. I searched google and a few forums about gameprogramming but noone was able to help me... so if you have some ideas please let me know

    shadowstrike

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default

    You haven't actually told us what your problem or question is.

    But to practice my mind-reading, I'd say you want to store the "key-down-ness" of the keys in question as a boolean, then check those booleans and perform the appropriate action in a Timer.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Shadowstrike is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    ok sorry xD
    so i want to write functions to handle keyboard input. the functions should be able to handle multiple pressed keys (so for example: a and x are pressed). The problem about that is that i don't know a way to do. google didn't help and the forums i searched didn't as well

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default

    Quote Originally Posted by Shadowstrike View Post
    ok sorry xD
    so i want to write functions to handle keyboard input. the functions should be able to handle multiple pressed keys (so for example: a and x are pressed). The problem about that is that i don't know a way to do. google didn't help and the forums i searched didn't as well
    Are you trying to determine when you should do two things at once (a does one thing and x does another, and you want to do both of them when both keys are pressed), or do you want to do one thing when the keys are pressed "at the same time"?

    What happened when you tried my suggestion?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Handling multiple WAV files and saving them into ONE
    By phil128 in forum Advanced Java
    Replies: 2
    Last Post: 12-11-2010, 02:31 PM
  2. Checking for multiple keys pressed
    By MagnusLarsen in forum New To Java
    Replies: 15
    Last Post: 08-22-2010, 11:51 AM
  3. Handling Errors IE: Wrong User Input
    By movsesinator in forum New To Java
    Replies: 4
    Last Post: 04-06-2010, 01:37 AM
  4. data structure with multiple keys
    By jon80 in forum New To Java
    Replies: 2
    Last Post: 06-13-2009, 03:02 PM
  5. Runtime.exec(), handling input and output streams
    By crookshank in forum New To Java
    Replies: 0
    Last Post: 06-05-2008, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •