Detect Shift key is pressed without using events in Windows Forms?

后端 未结 4 551
粉色の甜心
粉色の甜心 2021-01-01 20:05

I need to be able to detect that the shift key is being held, but I don\'t want to use events or global variables to determine that. Is there an API in C# that lets you ask

4条回答
  •  天涯浪人
    2021-01-01 20:30

    Not sure if this available in C# but you can call GetAsyncKeyState. This method returns the state of a key at the time the method is called.

    To call it from C# you'll need to use interop like any other Win32 API.

提交回复
热议问题