0

'{' 和 '}' 的 C# 键码是什么,所以我可以在KeyDown事件中使用它

if(e.KeyCode == Keys.CurlyBracket1)
{
    //Do stuff
}

对不起,有点模糊,但我不知道还能写什么

4

3 回答 3

5

On a Standard U.S. keyboard layout, the keys for { and } are OemOpenBrackets (or Oem4) and OemCloseBrackets (or Oem6), respectively. However, since these glyphs share a key with the square brackets ([, ]), you would need to test for the presence of one of the shift modifiers.

I would not assume this would work on all non-"Standard U.S." keyboard configurations; it would be better to handle the KeyPress event and check the KeyChar property.

于 2013-11-12T18:38:07.103 回答
2

Curley braces are not a Key on all keyboards, for example they require you to hold shift on a UK Qwerty keyboard therefore KeyDown will not work. You need to use the KeyPress event instead.

于 2013-11-12T18:38:07.277 回答
-3

检查它是否有用:http ://www.w3.org/2002/09/tests/keys.html

此致

于 2013-11-12T18:32:18.837 回答