why this doesn t work? | Sololearn: Learn to code for FREE!


why this doesn t work?

this is the code package controles; import java.awt.event.KeyListener; public final class teclado implements KeyListener{ private final static int numTeclas = 120; private final boolean[] teclas = new boolean[numTeclas]; public boolean arriba; public boolean abajo; public boolean izquierda; public boolean derecha; public void actualizar(){ arriba = teclas[KeyEvent.VK_W]; abajo = teclas[KeyEvent.VK_S]; izquierda = teclas[KeyEvent.VK_A]; derecha = teclas[KeyEvent.VK_D]; } public void KeyPressed(KeyEvent e){ teclas[e.getKeyCode()] = true; } public void KeyReleased(KeyEvent e){ teclas[e.getKeyCode()] = false; } public void KeyTyped(KeyEvent e){ } } the error is that keyevent does not recognize i don t know why

3/6/2017 3:53:47 PM

Ismael Perbech

2 Answers

New Answer


A simile suggestion: debug. Put a breakcode into KeyPressed method to see the value of "e"


' ok thnx