@Override
  public void keyPressed(KeyEvent e) {
    // Do not edit neural web while user is selecting key bindings
    if (expandContractKey.isActive()
        || newNeuronKey.isActive()
        || newClusterKey.isActive()
        || deleteKey.isActive()) return;

    try {
      if (e.getKeyChar() == expandContractKey.getText().charAt(0)) {
        if (selectedCluster != null && selectedCluster.clusterNum != 0)
          selectedCluster.expanded = !selectedCluster.expanded;
        else if (selectedNeuron != null)
          selectedNeuron.cluster.expanded = !selectedNeuron.cluster.expanded;

        redraw = true;
      } else if (e.getKeyChar() == newNeuronKey.getText().charAt(0)) {
        Cluster cluster;

        if (selectedCluster != null) cluster = selectedCluster;
        else if (selectedNeuron != null) cluster = selectedNeuron.cluster;
        else if (clusters.size() > 2) {
          cluster = clusters.get(2);
        } else {
          WindowTools.informationWindow(
              "Error: You cannot add a neuron without a cluster, please select a Neuron or a Cluster.",
              "Error");
          return;
        }

        int x = Math.min(Main.canvasWidth - 11, Math.max(10, mouseX));
        int y = Math.min(Main.canvasHeight - 33, Math.max(33, mouseY));

        neurons.add(new Neuron(x, y, cluster));

        redraw = true;
      } else if (e.getKeyChar() == newClusterKey.getText().charAt(0)) {
        int x = Math.min(Main.canvasWidth - 11, Math.max(10, mouseX));
        int y = Math.min(Main.canvasHeight - 33, Math.max(33, mouseY));

        clusters.add(new Cluster(x, y));

        redraw = true;
      } else if (e.getKeyChar() == deleteKey.getText().charAt(0)) {
        if (selectedCluster != null) selectedCluster.delete();
        else if (selectedNeuron != null) selectedNeuron.delete();
        else if (selectedConnection != null) selectedConnection.delete();

        redraw = true;
      }
    } catch (StringIndexOutOfBoundsException sioobe) {
      WindowTools.informationWindow(
          "Invalid keybinding, please select a character for each action.", "Whoops!");
    }
  }
  @Override
  protected void initiate() {
    mouseInteractionMenu = new TMenu(0, 0, Main.canvasWidth, 23, TMenu.HORIZONTAL);
    keyInteractionMenu =
        new TMenu(0, Main.canvasHeight - 23, Main.canvasWidth, 23, TMenu.HORIZONTAL);

    // Minimise wasted space in interactionMenus and align left
    mouseInteractionMenu.setBorderSize(1);
    mouseInteractionMenu.setTComponentSpacing(3);
    mouseInteractionMenu.setTComponentAlignment(TMenu.ALIGN_START);
    keyInteractionMenu.setBorderSize(1);
    keyInteractionMenu.setTComponentSpacing(3);
    keyInteractionMenu.setTComponentAlignment(TMenu.ALIGN_START);

    // Group RadioButtons in mouseInteraction menu
    leftClickSelections.add(leftSelectButton);
    rightClickSelections.add(rightConnectButton);
    rightClickSelections.add(rightDeleteButton);
    mouseDragSelections.add(dragMoveButton);
    mouseDragSelections.add(dragDeleteButton);

    // Add TComponents to mouseInteractionMenu
    mouseInteractionMenu.add(new TLabel("Left Click:"));
    mouseInteractionMenu.add(leftSelectButton);
    mouseInteractionMenu.add(new TLabel("Right Click:"));
    mouseInteractionMenu.add(rightConnectButton);
    mouseInteractionMenu.add(rightDeleteButton);
    mouseInteractionMenu.add(new TLabel("Mouse Drag:"));
    mouseInteractionMenu.add(dragMoveButton);
    mouseInteractionMenu.add(dragDeleteButton);

    // Add TComponents to keyInteractionMenu
    keyInteractionMenu.add(new TLabel("Show/Hide key"));
    keyInteractionMenu.add(expandContractKey, false);
    keyInteractionMenu.add(new TLabel("New Neuron key"));
    keyInteractionMenu.add(newNeuronKey, false);
    keyInteractionMenu.add(new TLabel("New Cluster key"));
    keyInteractionMenu.add(newClusterKey, false);
    keyInteractionMenu.add(new TLabel("Delete key"));
    keyInteractionMenu.add(deleteKey, false);
    keyInteractionMenu.add(newInputButton, false);
    keyInteractionMenu.add(newOutputButton, false);

    // Add interactionMenus to RenderableObject
    add(mouseInteractionMenu);
    add(keyInteractionMenu);

    // Set starting mouse interactions
    leftSelectButton.setChecked(true);
    rightConnectButton.setChecked(true);
    dragMoveButton.setChecked(true);

    // set starting key interactions
    expandContractKey.setText("s");
    newNeuronKey.setText("n");
    newClusterKey.setText("c");
    deleteKey.setText("d");

    organiseInputs();
    organiseOutputs();
  }