public void keyPressed(KeyEvent e) {
        if (moves == 0) {
            if (e.getKeyCode() == KeyEvent.VK_R)
                reset();
        }
        else if (e.getKeyCode() == KeyEvent.VK_I) {
            try{
                JFileChooser chooser = new JFileChooser();
                chooser.setFileFilter(new FileNameExtensionFilter("JPG & GIF Images", "jpg", "gif", "png"));
                int returnVal = chooser.showOpenDialog(this);
                if(returnVal == JFileChooser.APPROVE_OPTION) {
                    String path = chooser.getSelectedFile().getPath();
                    map = ImageIO.read(new File(path));
                    reset();
            }
        } catch (Exception ex) { System.exit(0); }
        }
        else {
            step(e.getKeyCode());
        }
        repaint();
    }