0

Wanting to know how to get the Android soft keyboard to open up without having to enter something into a field and how to get the key presses from the open keyboard.

Kai Hulme
  • 33
  • 9
  • 2
    Possible duplicate of [Close/hide the Android Soft Keyboard](http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard) – Chris Stillwell Nov 19 '15 at 22:02

1 Answers1

1

Kai -

To show the keyboard you can use the below code:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);

(as provided here https://stackoverflow.com/a/11155404)

To get the key presses without an input field focused, you can use the onKeyDown event handler like this:

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    // Capture keyCodes here

    return super.onKeyDown(keyCode, event); 
}
Community
  • 1
  • 1
TheGrandPackard
  • 591
  • 3
  • 11