C# 箭头键的键码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/330125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:26:15  来源:igfitidea点击:

Keycodes for arrow keys

c#winformskeypress

提问by Arun

Can anyone please help me to get the keycodes for the arrow keys in c# .net keypress events? Can you help me to get out of this check point?

任何人都可以帮我获取 c# .net 按键事件中箭头键的键码吗?你能帮我离开这个检查站吗?

best regards, Arun.

最好的问候,阿伦。

回答by JoshBerke

Do you mean the KeyUp event? KeyPress doesn't get fired for Arrows and the event args doesn't have a KeyCode property but for Arrow Keys in keyUp event they are:

你的意思是 KeyUp 事件?KeyPress 不会被 Arrows 触发,并且事件 args 没有 KeyCode 属性,但对于 keyUp 事件中的 Arrow Keys 它们是:

Keys.Up, Keys.Down, Keys.Left, Keys.right

Keys.Up, Keys.Down, Keys.Left, Keys.right

回答by shahkalpesh

回答by Ashu

You can look up the keycodes here: http://msdn.microsoft.com/en-in/library/aa243025(v=vs.60).aspx

您可以在此处查找密钥代码:http: //msdn.microsoft.com/en-in/library/aa243025(v=vs.60) .aspx

It states:

它指出:

vbKeyLeft   37  LEFT ARROW key
vbKeyUp     38  UP ARROW key
vbKeyRight  39  RIGHT ARROW key
vbKeyDown   40  DOWN ARROW key

You can use it to compare like this

你可以用它来比较

e.KeyValue==39