public void keyPressed(KeyEvent e) {
        int code = e.getKeyCode();
        // If n key is pressed generate new maze and start from scratch
        if (code == KeyEvent.VK_N) {
            this.runBFS = false;
            this.runDFS = false;
            this.bfs.toDo.clear();
            this.dfs.toDo.clear();
            this.maze = new Maze(this.maze.size);
            repaint();
        // If b key is pressed run a new breadth-first search
        } else if (code == KeyEvent.VK_B) {
            this.runDFS = false;
            this.runBFS = true;
            this.maze.searchPath.clear();
            this.maze.searchPath.add(new Point(1, 1));
            this.bfs = new BFS(this.maze.mst);
            this.dfs.toDo.clear();
            repaint();
        // If d key is pressed run a new depth-first search
        } else if (code == KeyEvent.VK_D) {
            this.runDFS = true;
            this.runBFS = false;
            this.maze.searchPath.clear();
            this.maze.searchPath.add(new Point(1, 1));
            this.dfs = new DFS(this.maze.mst);
            this.bfs.toDo.clear();
            repaint();
        } else if (code == KeyEvent.VK_SPACE) {
            this.showTree = !this.showTree;
        }
        e.consume();
    }