title: using keybinding and Action Map in Java for shortcut keys for buttons
body: <p>I am making a program where I want to have shortcuts for all the buttons in my program. example ctrl+a executes button 1. </p>
  
  <p>I also want these shortcuts to be user changeable </p>
  
  <p>so this is the code i am using to add a key binding </p>
  
  <pre><code>   InputMap IM = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
  
     IM.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, InputEvent.CTRL_DOWN_MASK | 
            InputEvent.ALT_DOWN_MASK), "BUTTON ONE ID");
  
    ActionMap actionMap = component.getActionMap();
      actionMap.put("BUTTON ONE ID", new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
              actionListener.actionPerformed(e);
          }
      });
  </code></pre>
  
  <p>Now since i want these to be user changeable, i want to be able to use the "BUTTON ONE ID" on the third line to get its information. I want to be able to know what key i entered for it and whether or not you need to hold ctrl or alt for the shortcut </p>
  
  <p>so i would want the following code</p>
  
  <pre><code>if("BUTTON ONE ID"){
    //print KeyEvent/keyCode info and if we need to hold ctrl, alt or shift?
    //and then i want to be able to change the key bindings 
  </code></pre>
  
  <p>}</p>
  
  <p>How do I do this using the "BUTTON ONE ID" or is their a better way of doing this. Thanks </p>