Press Escape key to call method

后端 未结 9 1968
南笙
南笙 2020-12-16 14:25

Is there a way to start a method in C# if a key is pressed? For example, Esc?

9条回答
  •  情书的邮戳
    2020-12-16 14:57

    You have to switch the form property "KeyPreview" to true or your events will not be fired. Handling these events alone will not do anything even though the events are correct. It will look to you like nothing really happens even though you have subscribed the proper event handlers.

提交回复
热议问题