Android app for Android capture without view edittext

How can I capture hardware keyboard events without using the EditText field?

For example, in a simple action, display a square on the screen when “B” is pressed on the slide keyboard. I want to turn it blue when "G" presses, turns it to green, etc.

I don't need help with the color code, just how to intercept a keystroke

This is not about a soft or virtual keyboard.

+5
source share
2 answers

Android classes typically provide event handlers that you can implement when you subclass them. The class Activityhas the following event handlers:

  • onKeyDown(int keyCode, KeyEvent event)
  • onKeyLongPress(int keyCode, KeyEvent event)
  • onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
  • onKeyShortcut(int keyCode, KeyEvent event)
  • onKeyUp(int keyCode, KeyEvent event)

, :

  • onKeyDown(int, KeyEvent)
  • onKeyUp(int, KeyEvent)

, , , . KeyEvent , .. key code.

+4

KeyEvent.CallBack .

,

+1

All Articles