c# – Capture key pressed Android


I am making an application for Android and I need to capture the keys that are pressed on the keyboard. I am new to Xamarin programming and it would help a lot if someone could guide me.


The common thing is to do it with the onKeyDown () method,

for example if we want to detect when the "Back" key is clicked:

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
        //Implemenetar accción,Se pulso la tecla back!
    return super.onKeyDown(keyCode, event);


  • Here you can find a list of all the constants, to detect any key:


  • You can also use the onKeyUp () method , but the difference is that it is executed when the key is released.
Scroll to Top