I'm doing my own input window with slick, user will need to type something into this. But when I type any letter I get more than one. I assume it depends on CPU, my current bypass is to sleep thread for 100 ms whenever I type. Is there any other way to do this and get only one letter ?
This is my code
if (input.isKeyDown(Input.KEY_0)) {
IPInput += "0";
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Based off of my comment....
You can substitute isKeyPressed()
in for isKeyDown()
.
KeyPress - triggered when the user presses a key and releases it (key down and then key up)
KeyDown - triggered when the user presses the key (key down)