title: Shortcut key for jButton without using alt key
body: <p>In SWT you can give any button a shortcut key simply by adding <code>&amp;</code> in front of the letter in the button label.  For example, if my button label is <code>&amp;Play</code>, I can activate the button by hitting letter <code>p</code> on the keyboard.</p>
  
  <p>In Swing, you can add a shortcut key using the <code>mnemonic</code> property.  However, you need to hit <code>alt+p</code> to activate the button.  This is really most appropriate for menu shortcuts.  I want to activate the button with a letter press and no alt modifier.</p>
  
  <p>I've seen this post on how to do it, but it seems absurdly complicated.  Is there an easier way to do this?</p>
  
  <p><a href="http://linuxjavaprogrammer.blogspot.com/2008/01/java-swing-jbutton-keyboard-shortcuts.html" rel="noreferrer">http://linuxjavaprogrammer.blogspot.com/2008/01/java-swing-jbutton-keyboard-shortcuts.html</a></p>
  
  <p><strong>Update:</strong> After @camickr suggestion, I ended up using this code.  I couldn't find any clear and simple example online, so hopefully this will help people out.</p>
  
  <pre><code>// play is a jButton but can be any component in the window
  play.getInputMap(play.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_P, 0), "play");
  play.getActionMap().put("play", new AbstractAction() {
  public void actionPerformed(ActionEvent e) {
    playActionPerformed(e);  // some function
  }
  });
  </code></pre>