title: Build a simple Keylogger Android Application: Accessibility research for Virtual keyboard
body: <p>I have been trying to find some resources in order to build a Keylogger Android application for an accessibility research project on the Android platform (APILevel 17).</p>
  <p>The Interface of the application would be a simple <strong>&quot;EditText&quot;</strong> field where the user types using the <em>virtual onscreen keyboard</em> [After selecting the required keyboard from the Input Settings].</p>
  <p>I aim to create a Keylog database for my application (with an SQLite DB because I'm familiar with that, but a simple csv file DB would also work well! :) ) which looks like the following:
  <img src="https://i.stack.imgur.com/uNX0o.png" alt="enter image description here" /> (Illustration)</p>
  <p>Hence I need to log each character on a new entry as soon as it is typed, along with the timestamp.
  I have been trying to expriment with the &quot;<strong><a href="http://developer.android.com/reference/android/text/TextWatcher.html" rel="nofollow noreferrer">TextWatcher</a></strong>&quot; Class</p>
  <pre><code>    EditText KeyLogEditText = (EditText) findViewById(R.id.editTextforKeyLog);
      TextWatcher KeyLogTextWatcher = new TextWatcher() {
          
          @Override
          public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) 
          {   }
          
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) 
          {   }
          
          @Override
          public void afterTextChanged(Editable arg0) {
      // TODO Log the characters in the SQLite DB with a timeStamp etc.
      // Here I call my database each time and insert an entry in the database table. 
      //I am yet to figure out how to find the latest-typed-character by user in the EditText 
                              
          }
  </code></pre>
  <p>My Questions are:</p>
  <ol>
  <li>Is this the Right way of Implementing this?</li>
  <li>Can I obtain Exactly ONE character that is typed along with the time and insert it into the SQLite DB which I can later obtain and analyse??</li>
  <li>Or Would the <a href="http://developer.android.com/reference/android/view/KeyEvent.Callback.html" rel="nofollow noreferrer">onKeyUp</a> Method be more useful? [I have not used tried method yet, So it would be great if someone could point me towards using this to build a keylogger if that's simpler!]</li>
  </ol>
  <p>*Thanks in Advance to anyone who can help me in any way!</p>
  <p>Adit*</p>