Check out example codes for "how to detect if a key is pressed in c#". It will help you in understanding the concepts better.

Code Example 1

//...
using System.Windows.Input;

class Main {
    public void Main() {
        while(true) {
            if(Keyboard.IsKeyPressed(Key.A)) {
                //...
            }
            return;
        }
    }
}

Learn ReactJs, React Native from akashmittal.com