Sending KeyEvents via ADB

1. Send a single KeyEvent
// Top of ur .cs file
...
using AndroidCtrl.ADB.Binary;
//or
using AndroidCtrl.ADB.Socket;
 
using AndroidCtrl.ADB.Device.Input;
...
 
// Sends a single key-event to the device
(bool)ADB.Instance().Device.Input.KeyEvent(AKey);
 
// Sends a single key-event with the long pressed flag to the device
(bool)ADB.Instance().Device.Input.KeyEvent(AKey key, bool longPress);
 
// Sends a single key-event with the long pressed flag from a specific input source to the device
(bool)ADB.Instance().Device.Input.KeyEvent(InputSource source, AKey key, bool longPress);
 
//Sends a single, mapped (102 keys "en" layout), key-event to the device
(bool)ADB.Instance().Device.Input.MappedKeyEvent(int key, KeyMap map, bool alt, bool shift)
 
//Sends a single, mapped (102 keys "en, de" layout), key-event to the device
(bool)ADB.Instance().Device.Input.MappedKeyEvent(int key, KeyMap map, string twoLetterISOLanguageName, bool alt, bool shift)
 

2. Send an KeyEvent stack
// Top of ur .cs file
...
using AndroidCtrl.ADB.Binary;
//or
using AndroidCtrl.ADB.Socket;
 
using AndroidCtrl.ADB.Device.Input;
...
 
// Create a List<AKey>
List<AKey> _stack = new List<AKey>()
{
    AKey.KEY_1,
    AKey.KEY_2,
    AKey.KEY_3
};
 
// and send the stack to the phone
(bool)ADB.Instance().Device.Input.KeyEventStack(_stack);
 
 
// Create a List<KeyEvent>
List<KeyEvent> _stack = new List<KeyEvent>()
{
    new KeyEvent(AKey.KEY_1),
    new KeyEvent(AKey.KEY_2, true),
    new KeyEvent(AKey.KEY_3, false)
};
 
// and send the stack to the phone
(bool)ADB.Instance().Device.Input.KeyEventStack(_stack);