Computer Science Canada

Event keyhandler

Author:  DanShadow [ Thu Jul 08, 2004 2:30 pm ]
Post subject:  Event keyhandler

Ive made a program that imports and draws graphics in a void called KeyDown with (Event e, int key). The problem is, it waits for input from the user before continuing. Can someone tell me how I might be able to have it so "IF" a user presses a key, it saves the ASCII (i belive) code under the variable "key" while using the variable "e" to track the event? Or just, like
code:

while (gameOn ==true)
{
    // Do graphics and stuff
    if ((e.id=KEY_PRESS) && (e.id=Event.UP))
    {
        y+=1;
    }
}

If you can help, thanks.

Author:  Dan [ Sat Jul 10, 2004 6:11 pm ]
Post subject: 

i am not shure how u are geting the events in e can u post the hole class? And what kind of java/APIs u are using?

If u are using keylistorners i whould think u could just put the code int the keyPressed method.


: