title: Keymap, InputMap, ActionMap, KeyListener — choice overload
body: <p>I couldn't find a concise answer about the relationships among all these, so that I can pick up best practices and get going. <a href="https://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html" rel="nofollow"><code>JTextComponent</code></a> has:</p>
  
  <ul>
  <li><p>The old <code>addKeyListener(..)</code>. We write a <code>KeyListener</code> with methods that get called on <code>keyPressed(..)</code>, <code>keyTyped(..)</code>, etc. events, which we can query: <code>event.getKeyCode()</code>.</p></li>
  <li><p><code>addKeymap(..)</code> and <code>setKeymap(..)</code>. A <code>Keymap</code> has <code>addActionForKeyStroke(..)</code>, which takes a <code>KeyStroke</code> (that we can get by calling <code>KeyStroke</code>'s static methods specifying the character or key code), and an <code>Action</code>, which is an <code>ActionListener</code> with bells and whistles.</p></li>
  <li><p><code>getInputMap(..)</code> and <code>getActionMap(..)</code>. An <code>InputMap</code> maps a <code>KeyStroke</code> (as above) to a <code>String</code>, and the <code>ActionMap</code> maps the string to an <code>Action</code> (as above). The Java Tutorial <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html" rel="nofollow"><em>How to use key bindings</em></a> talks about that.</p></li>
  </ul>
  
  <p>These are three redundant ways of attaining the same functionality. Besides comparative advantages/disadvantages, this raises the natural question of how these three mechanisms co-exist? Which ones take priority over others?</p>