void addKeyListener() {
        addKeyListener(new KeyAdapter() {
            
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_DELETE || e.getKeyCode() == KeyEvent.VK_BACK_SPACE) {
                    if (view.getCurrentlySelected() != null) {
                        if (view.getCurrentlySelected() instanceof EdgePainter) {
                            view.removeEdge((EdgePainter)view.getCurrentlySelected());
                        } else if (view.getCurrentlySelected() instanceof VertexPainter) {
                            view.removeVertex((VertexPainter)view.getCurrentlySelected());
                        }
                        view.setCurrentlySelected(null);
                    }
                }
            }
        });
    }