@Override public void keyPressed(KeyEvent e) { super.keyPressed(e); keyPressed.add(Key.getKey(e.getKeyCode())); char c = e.getKeyChar(); if (Character.isDefined(c)) charPressed.add(e.getKeyChar()); }
public void keyPressed(KeyEvent e) { // Game.warn("Focus owned by: // "+KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); // Game.warn(""+e.getKeyChar()); // call the currently registered keyhandler if (keyhandler != null) { keyhandler.keyPressed(e); } else { Game.getUserinterface().go(e); } }
@Override public void keyPressed(KeyEvent e) { super.keyPressed(e); if (e.getKeyCode() == KeyEvent.VK_LEFT) { game.MoveLeft(); } if (e.getKeyCode() == KeyEvent.VK_RIGHT) { game.MoveRight(); } if (e.getKeyCode() == KeyEvent.VK_UP) { game.MoveUp(); } if (e.getKeyCode() == KeyEvent.VK_DOWN) { game.MoveDown(); } if (e.getKeyCode() == KeyEvent.VK_SPACE) { game.shot(); } if (e.getKeyCode() == KeyEvent.VK_R) { game.resetLevel(); } if (e.getKeyCode() == KeyEvent.VK_A) { game.changePlayerAppearance(); } if (e.getKeyCode() == KeyEvent.VK_S) { game.changeMute(); } if (e.getKeyCode() == KeyEvent.VK_Q) { game.changeSBVisible(); } if (e.getKeyCode() == KeyEvent.VK_T) { game.changeTemplate(); } if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { // TODO: end the game } repaint(); }
@Override public void keyReleased(KeyEvent e) { super.keyReleased(e); keyPressed.remove(Key.getKey(e.getKeyCode())); keyTyped.add(Key.getKey(e.getKeyCode())); }