// ***************** KeyListener **************** @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub if (e.getKeyCode() == 8) // if delete key is pressed { MoleculeComponent currentElement = elist.getSelected(); if (currentElement != null) { // Clear any lines being drawn (cancel connections) drawBondLine = false; drawArrowLine = false; elist.removeSelected(); mmc.view.displayAttributes(null); repaint(); } } else if (e.getKeyCode() == e.VK_ESCAPE) // if user hits ESC { if (drawBondLine == true) // and there is a bond being drawn { drawBondLine = false; // cancel that bond repaint(); } } }