32 lines
660 B
Java
32 lines
660 B
Java
|
|
import java.awt.event.KeyListener;
|
||
|
|
import java.awt.event.KeyEvent;
|
||
|
|
import java.util.ArrayDeque;
|
||
|
|
|
||
|
|
public class ControleurClavier implements KeyListener {
|
||
|
|
|
||
|
|
private ArrayDeque<String> touches;
|
||
|
|
|
||
|
|
public ControleurClavier() {
|
||
|
|
this.touches = new ArrayDeque<>();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void keyPressed(KeyEvent e) {
|
||
|
|
if (this.touches.isEmpty() || !this.touches.getLast().equals(KeyEvent.getKeyText(e.getKeyCode()))) {
|
||
|
|
this.touches.addLast(KeyEvent.getKeyText(e.getKeyCode()));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void keyReleased(KeyEvent e) {
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void keyTyped(KeyEvent e) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public ArrayDeque<String> getTouches() {
|
||
|
|
return this.touches;
|
||
|
|
}
|
||
|
|
}
|