Detect if any key is pressed in C# (not A, B, but any)

前端 未结 9 2326
粉色の甜心
粉色の甜心 2020-12-01 08:32

[EDIT 3] I kind of "solved it" by at using the "strange" version. At least for the most important keys. It is suffient for my case, where I want to check

9条回答
  •  猫巷女王i
    2020-12-01 09:12

    Where is this code running from? Is it in an event handler? Many forms and controls will fire a KeyPress event as well as a KeyDown event. You may want to look into those events and set your flag to true when one of them occurs. You'd also have to listen for the corresponding event that tells you when the key is released (KeyUp, also, I think).

提交回复
热议问题