Hi all,
What i need to do is have slick listen to keyboard input and add each keystroke to a string variable. Anyone know how to do this in slick?
Hi all,
What i need to do is have slick listen to keyboard input and add each keystroke to a string variable. Anyone know how to do this in slick?
Input i = GameContainer.getInput()
i.addKeyListener(new MyKeyListener());
class MyInputListener implements KeyListener {
public void keyPressed(int key, char c) {
}
public void keyReleased(int key, char c) {
}
}
Thank you for the help Ra,
I Have added in these classes and methods but im still unsure of the work flow.
Could you add a line of code that prints the keyPressed to screen for example?
Sorry im really stuck on this one.
The keyPressed and keyReleased methods are called as soon as a key is pressed/released. Not much more to it.
public void keyPressed(int key, char c) {
System.out.println("You just pressed: " + c);
}
Thanks Ra i just had it in the wrong location.