@Override
    public void keyPressed(KeyEvent e) 
    {
        //This is a set instead of a list because holding down a key will call
        //this function many times in a row. You cannot guarentee that there is
        //only one press per release like you can with a click.
        protectKeyList.acquireUninterruptibly();
        keysPressed.add(e.getKeyCode());
        protectKeyList.release();
    }