How can I detect that the Shift key has been pressed?

前端 未结 7 1081
甜味超标
甜味超标 2020-12-10 00:37

I have a NSView subclass and I would like it to react when the user presses the ⇧ Shift key. However, -[NSView keyDown:] (which I curren

7条回答
  •  执念已碎
    2020-12-10 01:24

    What do you do if the key press does not come as an event? For example, you want to test the state of the Shift key when the program starts up? The Shift key was pressed before the program started, and will not be released until after you test its state.

    In Windows, you can easily get this with a call to GetKeyState(VK_SHIFT). What is the macOS equivalent?

提交回复
热议问题