title: Intercept all touch data (including keyboard)
body: <p>I am currently investigating the ways in which touchscreen data can be retrieved in android.</p>
  
  <p><em>Before I continue, the app will be used for research purposes and will be utilising all sensory inputs for an experiment. The app is not intended for public release. Users will know all of their inputs are being monitored.</em></p>
  
  <p>I basically want to monitor all touch inputs on the phone screen, including keyboard presses etc. I have been able to get general touch events:</p>
  
  <pre><code>public override bool OnTouchEvent(MotionEvent e)
  {
      int x = (int)e.GetX();
      int y = (int)e.GetY();
  
      System.Diagnostics.Debug.WriteLine($"Touch detected at x:{x} y:{y}");
  
      return base.OnTouchEvent(e);
  }
  </code></pre>
  
  <p>But this method won't get called for the following situations:</p>
  
  <ol>
  <li>Another item in the view is tapped (not the view itself, ie a button).</li>
  <li>The keyboard is presented</li>
  </ol>
  
  <p>I want to be able to get touch data for any touch that occurs on the phone's screen. I have included a screenshot below of the sort of screen tap's I am interested in capturing.</p>
  
  <p>Is this possible with the default keyboard? I'm likely to use Xamarin Android to implement this project (as I've alot more experience of xamarin than I do of android). I'd much prefer to stay as vanilla as possible.</p>
  
  <p>Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/nprG1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nprG1.png" alt="Screenshot of the touch events I want to intercept"></a></p>