title: Java Set Text Field Text As Key Pressed
body: <p>I am working on an auto clicker where a user may set a custom hot key.</p>
  
  <p>I currently have the below function which accepts a key to be assigned as the hotkey and then is supposed to set the text of the hotkey textfield to be the key that was pressed.</p>
  
  <p>I do not want the key's actual name, or it's character. I want it's 'picture' so to speak. So as if I actually typed the key into the text field I want that character to show. So for example, if I want to set the hotkety as the tilde (`) then it should appear like so in the text field.</p>
  
  <pre><code>KeyboardFocusManager.getCurrentKeyboardFocusManager()
                          .addKeyEventDispatcher(new KeyEventDispatcher() {
                              @Override
                              public boolean dispatchKeyEvent(KeyEvent e) {
                                  int keycode = e.getKeyCode();
                                  hotkeyField.setText("");
                                  KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
                                  return false;
                              }
                          });
  </code></pre>
  
  <p>Thanks in advance.</p>