C# Detect ESC press key anywhere

前端 未结 3 1812
执念已碎
执念已碎 2020-12-20 08:16

I have a C# windowed application running and I want to close it when I press ESC from anywhere, even when my application does not have focus. How can I implement this?

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-20 08:25

    if you want you can set global hook with http://www.codeproject.com/Articles/7294/Processing-Global-Mouse-and-Keyboard-Hooks-in-C

提交回复
热议问题