public void keyPressed(KeyEvent e) {
		// Packet sent for any type of key event. So create the packet first
		Packet event = null;

		// Create event packet according to key event
		// If the user pressed Q, invoke the cleanup code and quit. 
		if((e.getKeyChar() == 'q') || (e.getKeyChar() == 'Q')) {
			event = new Packet(Packet.Type.QUIT, use_packet().intValue(), getID());
		// Up-arrow moves forward.
		} else if(e.getKeyCode() == KeyEvent.VK_UP) {
			event = new Packet(Packet.Type.FWD, use_packet().intValue(), getID());
		// Down-arrow moves backward.
		} else if(e.getKeyCode() == KeyEvent.VK_DOWN) {
			event = new Packet(Packet.Type.BACK, use_packet().intValue(), getID());
		// Left-arrow turns left.
		} else if(e.getKeyCode() == KeyEvent.VK_LEFT) {
			event = new Packet(Packet.Type.LEFT, use_packet().intValue(), getID());
		// Right-arrow turns right.
		} else if(e.getKeyCode() == KeyEvent.VK_RIGHT) {
			event = new Packet(Packet.Type.RIGHT, use_packet().intValue(), getID());
		// Spacebar fires.
		} else if(e.getKeyCode() == KeyEvent.VK_SPACE) {
			event = new Packet(Packet.Type.FIRE, use_packet().intValue(), getID());
		} else { // Unhandeled key event. Simply ignored
			return;
		}
		assert(event != null);
		
		// Send request to server
		try{
        	System.out.println(this.getName() + ": requesting action " + event.type);
			out.writeObject(event);
        } catch (IOException ex){
        	System.err.println("GUIClient: Failed to send movement request.");
            ex.printStackTrace();
        } catch (Exception ex) {
        	System.err.println("GUIClient: Failed to send movement request");
            ex.printStackTrace();
        }
	}