@Override
    public void keyPressed(KeyEvent e)
    {
        if (gameRunning)
        {
            /*
             * If the change in direction cannot be applied immediately, keep
             * track of the direction specified in case the change in 
             * direction can be applied later.
             */
            switch (e.getKeyCode())
            {
                case KeyEvent.VK_UP:
                    if (!objects.isWallAtPosition(x, y - speed))
                    {
                        facing = Direction.UP;
                        inputDelay = 0;
                    }
                    else
                    {
                        previousInput = Direction.UP;
                        inputDelay = 30;
                    }

                    break;

                case KeyEvent.VK_DOWN:
                    if (!objects.isWallAtPosition(x, getBottom() + speed))
                    {
                        facing = Direction.DOWN;
                        inputDelay = 0;
                    }
                    else
                    {
                        previousInput = Direction.DOWN;
                        inputDelay = 30;
                    }

                    break;

                case KeyEvent.VK_LEFT:
                    if (!objects.isWallAtPosition(x - speed, y))
                    {
                        facing = Direction.LEFT;
                        inputDelay = 0;
                    }
                    else
                    {
                        previousInput = Direction.LEFT;
                        inputDelay = 30;
                    }

                    break;

                case KeyEvent.VK_RIGHT:
                    if (!objects.isWallAtPosition(getRight() + speed, y))
                    {
                        facing = Direction.RIGHT;
                        inputDelay = 0;
                    }
                    else
                    {
                        previousInput = Direction.RIGHT;
                        inputDelay = 30;
                    }

                    break;
            }
        }
    }