Chrome üzerindeyken ESC tuşunu kontrol etmek istiyorsan 2 şey yapmanız gerekiyor. Windows API'den ESC tuşunun basılıp basılmadığını kontrol etnej ve bu kontrolü arka planda sürekli olarak gerçekleştirmek. Bunun için InteropServices kullanmak gerekiyor.
[CODE lang="csharp" title="C#"]public static const int BTN_ESC = 0x1B; //ESC tuşunun kodu.
[DllImport("user32.dll")]
public static extern short GetAsyncKeyState(int key);
//Windows API'den parametrede verilen tuşun basılıp basılmadığını çekiyoruz.
//Bu metod C++ metodu olduğundan InteropServices kullanmamız gerekti.
public bool KontrolEtESC()
{
short state = GetAsyncKeyState(BTN_ESC);
return state > 0;
}
//Gelen değer 0'dan büyükse tuşa basılıyor demektir.[/CODE]
Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
docs.microsoft.com
The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order.
docs.microsoft.com
Bir de bunu sürekli kontrol edecek bir Thread mekanizmasına ihtiyacınız var. Bunu da araştırarak yapabilirsiniz.