title: Creating a SoftKeyboard with Multiple/Alternate characters per key
body: <p>I've followed the examples on <a href="http://developer.android.com/" rel="noreferrer">developer.android.com</a> regarding  <a href="http://developer.android.com/resources/articles/creating-input-method.html" rel="noreferrer">Input Methods</a> and played with the <a href="http://developer.android.com/resources/samples/SoftKeyboard/index.html" rel="noreferrer">SoftKeyboard</a> sample application. These together give more than enough information regarding the creation of simple keyboard.</p>
  
  <p>What I can't see in the API is the ability to create alternate / multiple characters per key which is available on the standard Keyboard (LatinIME Keyboard).</p>
  
  <p><img src="https://i.stack.imgur.com/dhkHH.png" alt="enter image description here"></p>
  
  <p>The above image is the result of a long press on the "a" key. When you long press a key it's possible to populate a popup with alternate characters.</p>
  
  <p><img src="https://i.stack.imgur.com/FYLdY.png" alt="enter image description here"></p>
  
  <p>It is also possible to give a popup hint on some keys which will prompt the user to press and hold a key in order to get the popup menu.</p>
  
  <p>So far I haven't found a single source of information on how this is achieved, hopefully someone will be able to give me a head start, until then I'll follow the source code of the inbuilt keyboard and see if I can reverse engineer it.</p>
  
  <p><strong>Edit:</strong> Would help if <a href="http://developer.android.com/" rel="noreferrer">developer.android.com</a> 's link to the LatinIME Keyboard didn't link to a picture of a <a href="http://android.git.kernel.org/?p=platform/packages/inputmethods/LatinIME.git;a=tree" rel="noreferrer">Sheep</a> :) Actual source code for <a href="http://www.google.com/codesearch#cZwlSNS7aEw/packages/inputmethods/LatinIME/java/src/com/android/inputmethod/latin/LatinIME.java&amp;type=cs" rel="noreferrer">LatinIME.java</a>.</p>
  
  <p><strong>Edit 2:</strong> More as a reference than anything else, this is the sequence I believe a usual longPress action goes through in order to show the popup keyboard in <a href="http://www.google.com/codesearch#cZwlSNS7aEw/frameworks/base/core/java/android/inputmethodservice/KeyboardView.java" rel="noreferrer">KeyboardView.java</a>:</p>
  
  <pre><code>onTouchEvent()
  onModifiedTouchEvent()
  mHandkler.handleMessage() with MSG_LONGPRESS
  openPopupIfRequired() 
  onLongPress()
  </code></pre>
  
  <p><strong>Edit 3:</strong> </p>
  
  <p>I still haven't figured this out - How do you add label suggestions to keys? An answer suggests it isn't built into the API and indeed I haven't found the codeto do this. However the Keyboard on 2.3.4 (API 10) shows this functionality being implemented:</p>
  
  <p><img src="https://i.stack.imgur.com/GSz0v.png" alt="enter image description here"></p>
  
  <p>Would very much like to figure out how IT does it but it isn't anywhere in the <code>onDraw()</code> method that I can see - which makes me believe it's being written outside of the KeyboardView element. I can't however find the <code>layout</code> file used to display the KeyboardView element on the inbuilt keyboard - If anyone knows where to find this perhaps that will give me the clue I need.</p>
  
  <p><strong>Edit 4:</strong> Moved key Preview question here as it's slightly off topic:</p>
  
  <p><a href="https://stackoverflow.com/q/7770099/726954">How do you disable the SoftKeyboard key preview window?</a></p>