[source lang="java]
package com.mojang.escape;
import java.awt.event.*;
public class InputHandler implements KeyListener, FocusListener, MouseListener, MouseMotionListener {
public boolean[] keys = new boolean[65536];
public void mouseDragged(MouseEvent arg0) {
}
public void mouseMoved(MouseEvent arg0) {
}
public void mouseClicked(MouseEvent arg0) {
}
public void mouseEntered(MouseEvent arg0) {
}
public void mouseExited(MouseEvent arg0) {
}
public void mousePressed(MouseEvent arg0) {
}
public void mouseReleased(MouseEvent arg0) {
}
public void focusGained(FocusEvent arg0) {
}
public void focusLost(FocusEvent arg0) {
for (int i=0; i<keys.length; i++) {
keys = false;
}
}
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
if (code>0 && code<keys.length) {
keys
= true;
}
}
public void keyReleased(KeyEvent e) {
int code = e.getKeyCode();
if (code>0 && code<keys.length) {
keys = false;
}
}
public void keyTyped(KeyEvent arg0) {
}
}
[/source]
Should I really use this design for my input detection class? What should I do with the wasted boolean array? Note that all of the Listeners were implemented for future use. Any suggestions were fine, just that whenever I think of it, it's cringes my mind a lot of OCDness.