Keys Keys Keys Keys Enum

定义

指定键代码和修饰符。Specifies key codes and modifiers.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class Keys
[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.KeysConverter))]
[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum Keys
type Keys = 
Public Enum Keys
继承
属性

字段

A A A A 65

A 键。The A key.

Add Add Add Add 107

加号键。The add key.

Alt Alt Alt Alt 262144

ALT 修改键。The ALT modifier key.

Apps Apps Apps Apps 93

应用程序键 (Microsoft Natural Keyboard)。The application key (Microsoft Natural Keyboard).

Attn Attn Attn Attn 246

ATTN 键。The ATTN key.

B B B B 66

B 键。The B key.

Back Back Back Back 8

BACKSPACE 键。The BACKSPACE key.

BrowserBack BrowserBack BrowserBack BrowserBack 166

在浏览器后退键 (Windows 2000 或更高版本)。The browser back key (Windows 2000 or later).

BrowserFavorites BrowserFavorites BrowserFavorites BrowserFavorites 171

浏览器收藏夹键 (Windows 2000 或更高版本)。The browser favorites key (Windows 2000 or later).

BrowserForward BrowserForward BrowserForward BrowserForward 167

在浏览器前进键 (Windows 2000 或更高版本)。The browser forward key (Windows 2000 or later).

BrowserHome BrowserHome BrowserHome BrowserHome 172

浏览器主页键 (Windows 2000 或更高版本)。The browser home key (Windows 2000 or later).

BrowserRefresh BrowserRefresh BrowserRefresh BrowserRefresh 168

浏览器刷新键 (Windows 2000 或更高版本)。The browser refresh key (Windows 2000 or later).

BrowserSearch BrowserSearch BrowserSearch BrowserSearch 170

浏览器搜索键 (Windows 2000 或更高版本)。The browser search key (Windows 2000 or later).

BrowserStop BrowserStop BrowserStop BrowserStop 169

浏览器停止键 (Windows 2000 或更高版本)。The browser stop key (Windows 2000 or later).

C C C C 67

C 键。The C key.

Cancel Cancel Cancel Cancel 3

CANCEL 键。The CANCEL key.

Capital Capital Capital Capital 20

CAPS LOCK 键。The CAPS LOCK key.

CapsLock CapsLock CapsLock CapsLock 20

CAPS LOCK 键。The CAPS LOCK key.

Clear Clear Clear Clear 12

CLEAR 键。The CLEAR key.

Control Control Control Control 131072

CTRL 修改键。The CTRL modifier key.

ControlKey ControlKey ControlKey ControlKey 17

CTRL 键。The CTRL key.

Crsel Crsel Crsel Crsel 247

CRSEL 键。The CRSEL key.

D D D D 68

D 键。The D key.

D0 D0 D0 D0 48

0 键。The 0 key.

D1 D1 D1 D1 49

1 键。The 1 key.

D2 D2 D2 D2 50

2 键。The 2 key.

D3 D3 D3 D3 51

3 键。The 3 key.

D4 D4 D4 D4 52

4 键。The 4 key.

D5 D5 D5 D5 53

5 键。The 5 key.

D6 D6 D6 D6 54

6 键。The 6 key.

D7 D7 D7 D7 55

7 键。The 7 key.

D8 D8 D8 D8 56

8 键。The 8 key.

D9 D9 D9 D9 57

9 键。The 9 key.

Decimal Decimal Decimal Decimal 110

句点键。The decimal key.

Delete Delete Delete Delete 46

DEL 键。The DEL key.

Divide Divide Divide Divide 111

除号键。The divide key.

Down Down Down Down 40

DOWN ARROW 键。The DOWN ARROW key.

E E E E 69

E 键。The E key.

End End End End 35

END 键。The END key.

Enter Enter Enter Enter 13

ENTER 键。The ENTER key.

EraseEof EraseEof EraseEof EraseEof 249

ERASE EOF 键。The ERASE EOF key.

Escape Escape Escape Escape 27

ESC 键。The ESC key.

Execute Execute Execute Execute 43

EXECUTE 键。The EXECUTE key.

Exsel Exsel Exsel Exsel 248

EXSEL 键。The EXSEL key.

F F F F 70

F 键。The F key.

F1 F1 F1 F1 112

F1 键。The F1 key.

F10 F10 F10 F10 121

F10 键。The F10 key.

F11 F11 F11 F11 122

F11 键。The F11 key.

F12 F12 F12 F12 123

F12 键。The F12 key.

F13 F13 F13 F13 124

F13 键。The F13 key.

F14 F14 F14 F14 125

F14 键。The F14 key.

F15 F15 F15 F15 126

F15 键。The F15 key.

F16 F16 F16 F16 127

F16 键。The F16 key.

F17 F17 F17 F17 128

F17 键。The F17 key.

F18 F18 F18 F18 129

F18 键。The F18 key.

F19 F19 F19 F19 130

F19 键。The F19 key.

F2 F2 F2 F2 113

F2 键。The F2 key.

F20 F20 F20 F20 131

F20 键。The F20 key.

F21 F21 F21 F21 132

F21 键。The F21 key.

F22 F22 F22 F22 133

F22 键。The F22 key.

F23 F23 F23 F23 134

F23 键。The F23 key.

F24 F24 F24 F24 135

F24 键。The F24 key.

F3 F3 F3 F3 114

F3 键。The F3 key.

F4 F4 F4 F4 115

F4 键。The F4 key.

F5 F5 F5 F5 116

F5 键。The F5 key.

F6 F6 F6 F6 117

F6 键。The F6 key.

F7 F7 F7 F7 118

F7 键。The F7 key.

F8 F8 F8 F8 119

F8 键。The F8 key.

F9 F9 F9 F9 120

F9 键。The F9 key.

FinalMode FinalMode FinalMode FinalMode 24

IME 最终模式键。The IME final mode key.

G G G G 71

G 键。The G key.

H H H H 72

H 键。The H key.

HanguelMode HanguelMode HanguelMode HanguelMode 21

IME Hanguel 模式键。The IME Hanguel mode key. (为了保持兼容; 使用HangulMode)(maintained for compatibility; use HangulMode)

HangulMode HangulMode HangulMode HangulMode 21

IME Hangul 模式键。The IME Hangul mode key.

HanjaMode HanjaMode HanjaMode HanjaMode 25

IME Hanja 模式键。The IME Hanja mode key.

Help Help Help Help 47

HELP 键。The HELP key.

Home Home Home Home 36

HOME 键。The HOME key.

I I I I 73

I 键。The I key.

IMEAccept IMEAccept IMEAccept IMEAccept 30

IME 接受键,替换IMEAceeptThe IME accept key, replaces IMEAceept.

IMEAceept IMEAceept IMEAceept IMEAceept 30

IME 接受键。The IME accept key. 已过时,请使用IMEAccept相反。Obsolete, use IMEAccept instead.

IMEConvert IMEConvert IMEConvert IMEConvert 28

IME 转换键。The IME convert key.

IMEModeChange IMEModeChange IMEModeChange IMEModeChange 31

IME 模式更改键。The IME mode change key.

IMENonconvert IMENonconvert IMENonconvert IMENonconvert 29

IME 非转换键。The IME nonconvert key.

Insert Insert Insert Insert 45

INS 键。The INS key.

J J J J 74

J 键。The J key.

JunjaMode JunjaMode JunjaMode JunjaMode 23

IME Junja 模式键。The IME Junja mode key.

K K K K 75

K 键。The K key.

KanaMode KanaMode KanaMode KanaMode 21

IME Kana 模式键。The IME Kana mode key.

KanjiMode KanjiMode KanjiMode KanjiMode 25

IME Kanji 模式键。The IME Kanji mode key.

KeyCode KeyCode KeyCode KeyCode 65535

从键值提取键代码的位屏蔽。The bitmask to extract a key code from a key value.

L L L L 76

L 键。The L key.

LaunchApplication1 LaunchApplication1 LaunchApplication1 LaunchApplication1 182

启动应用程序一个键 (Windows 2000 或更高版本)。The start application one key (Windows 2000 or later).

LaunchApplication2 LaunchApplication2 LaunchApplication2 LaunchApplication2 183

启动应用程序二键 (Windows 2000 或更高版本)。The start application two key (Windows 2000 or later).

LaunchMail LaunchMail LaunchMail LaunchMail 180

启动邮件键 (Windows 2000 或更高版本)。The launch mail key (Windows 2000 or later).

LButton LButton LButton LButton 1

鼠标左键。The left mouse button.

LControlKey LControlKey LControlKey LControlKey 162

左 CTRL 键。The left CTRL key.

Left Left Left Left 37

LEFT ARROW 键。The LEFT ARROW key.

LineFeed LineFeed LineFeed LineFeed 10

LINEFEED 键。The LINEFEED key.

LMenu LMenu LMenu LMenu 164

左 ALT 键。The left ALT key.

LShiftKey LShiftKey LShiftKey LShiftKey 160

左的 SHIFT 键。The left SHIFT key.

LWin LWin LWin LWin 91

左 Windows 徽标键 (Microsoft Natural Keyboard)。The left Windows logo key (Microsoft Natural Keyboard).

M M M M 77

M 键。The M key.

MButton MButton MButton MButton 4

鼠标中按钮 (三个按钮的鼠标)。The middle mouse button (three-button mouse).

MediaNextTrack MediaNextTrack MediaNextTrack MediaNextTrack 176

媒体下一曲目键 (Windows 2000 或更高版本)。The media next track key (Windows 2000 or later).

MediaPlayPause MediaPlayPause MediaPlayPause MediaPlayPause 179

媒体播放暂停键 (Windows 2000 或更高版本)。The media play pause key (Windows 2000 or later).

MediaPreviousTrack MediaPreviousTrack MediaPreviousTrack MediaPreviousTrack 177

媒体上一曲目键 (Windows 2000 或更高版本)。The media previous track key (Windows 2000 or later).

MediaStop MediaStop MediaStop MediaStop 178

媒体停止键 (Windows 2000 或更高版本)。The media Stop key (Windows 2000 or later).

Menu Menu Menu Menu 18

ALT 键。The ALT key.

Modifiers Modifiers Modifiers Modifiers -65536

从键值提取修饰符的位屏蔽。The bitmask to extract modifiers from a key value.

Multiply Multiply Multiply Multiply 106

乘号键。The multiply key.

N N N N 78

N 键。The N key.

Next Next Next Next 34

PAGE DOWN 键。The PAGE DOWN key.

NoName NoName NoName NoName 252

留待将来使用的常数。A constant reserved for future use.

None None None None 0

不按任何键。No key pressed.

NumLock NumLock NumLock NumLock 144

NUM LOCK 键。The NUM LOCK key.

NumPad0 NumPad0 NumPad0 NumPad0 96

数字键盘上的 0 键。The 0 key on the numeric keypad.

NumPad1 NumPad1 NumPad1 NumPad1 97

数字键盘上的 1 键。The 1 key on the numeric keypad.

NumPad2 NumPad2 NumPad2 NumPad2 98

数字键盘上的 2 键。The 2 key on the numeric keypad.

NumPad3 NumPad3 NumPad3 NumPad3 99

数字键盘上的 3 键。The 3 key on the numeric keypad.

NumPad4 NumPad4 NumPad4 NumPad4 100

数字键盘上的 4 键。The 4 key on the numeric keypad.

NumPad5 NumPad5 NumPad5 NumPad5 101

数字键盘上的 5 键。The 5 key on the numeric keypad.

NumPad6 NumPad6 NumPad6 NumPad6 102

数字键盘上的 6 键。The 6 key on the numeric keypad.

NumPad7 NumPad7 NumPad7 NumPad7 103

数字键盘上的 7 键。The 7 key on the numeric keypad.

NumPad8 NumPad8 NumPad8 NumPad8 104

数字键盘上的 8 键。The 8 key on the numeric keypad.

NumPad9 NumPad9 NumPad9 NumPad9 105

数字键盘上的 9 键。The 9 key on the numeric keypad.

O O O O 79

O 键。The O key.

Oem1 Oem1 Oem1 Oem1 186

OEM 1 键。The OEM 1 key.

Oem102 Oem102 Oem102 Oem102 226

OEM 102 键。The OEM 102 key.

Oem2 Oem2 Oem2 Oem2 191

OEM 2 键。The OEM 2 key.

Oem3 Oem3 Oem3 Oem3 192

OEM 3 键。The OEM 3 key.

Oem4 Oem4 Oem4 Oem4 219

OEM 4 键。The OEM 4 key.

Oem5 Oem5 Oem5 Oem5 220

OEM 5 键。The OEM 5 key.

Oem6 Oem6 Oem6 Oem6 221

OEM 6 键。The OEM 6 key.

Oem7 Oem7 Oem7 Oem7 222

OEM 7 键。The OEM 7 key.

Oem8 Oem8 Oem8 Oem8 223

OEM 8 键。The OEM 8 key.

OemBackslash OemBackslash OemBackslash OemBackslash 226

OEM 尖括号或 RT 102 键键盘 (Windows 2000 或更高版本) 上的反斜杠键。The OEM angle bracket or backslash key on the RT 102 key keyboard (Windows 2000 or later).

OemClear OemClear OemClear OemClear 254

CLEAR 键。The CLEAR key.

OemCloseBrackets OemCloseBrackets OemCloseBrackets OemCloseBrackets 221

美式标准键盘 (Windows 2000 或更高版本) 上 OEM 右大括号键。The OEM close bracket key on a US standard keyboard (Windows 2000 or later).

Oemcomma Oemcomma Oemcomma Oemcomma 188

任何国家/地区键盘 (Windows 2000 或更高版本) 上的 OEM 逗号键。The OEM comma key on any country/region keyboard (Windows 2000 or later).

OemMinus OemMinus OemMinus OemMinus 189

OEM 减号键 (Windows 2000 或更高版本) 任何国家/地区键盘上。The OEM minus key on any country/region keyboard (Windows 2000 or later).

OemOpenBrackets OemOpenBrackets OemOpenBrackets OemOpenBrackets 219

美式标准键盘 (Windows 2000 或更高版本) 上 OEM 左大括号键。The OEM open bracket key on a US standard keyboard (Windows 2000 or later).

OemPeriod OemPeriod OemPeriod OemPeriod 190

任何国家/地区键盘 (Windows 2000 或更高版本) 上的 OEM 句点键。The OEM period key on any country/region keyboard (Windows 2000 or later).

OemPipe OemPipe OemPipe OemPipe 220

美式标准键盘 (Windows 2000 或更高版本) 上 OEM 管道键。The OEM pipe key on a US standard keyboard (Windows 2000 or later).

Oemplus Oemplus Oemplus Oemplus 187

OEM 加号键 (Windows 2000 或更高版本) 任何国家/地区键盘上。The OEM plus key on any country/region keyboard (Windows 2000 or later).

OemQuestion OemQuestion OemQuestion OemQuestion 191

美式标准键盘 (Windows 2000 或更高版本) 上 OEM 问号键。The OEM question mark key on a US standard keyboard (Windows 2000 or later).

OemQuotes OemQuotes OemQuotes OemQuotes 222

OEM 单/双引号键美式标准键盘 (Windows 2000 或更高版本) 上。The OEM singled/double quote key on a US standard keyboard (Windows 2000 or later).

OemSemicolon OemSemicolon OemSemicolon OemSemicolon 186

美式标准键盘 (Windows 2000 或更高版本) 上的 OEM 分号键。The OEM Semicolon key on a US standard keyboard (Windows 2000 or later).

Oemtilde Oemtilde Oemtilde Oemtilde 192

美式标准键盘 (Windows 2000 或更高版本) 上 OEM 颚化符键。The OEM tilde key on a US standard keyboard (Windows 2000 or later).

P P P P 80

P 键。The P key.

Pa1 Pa1 Pa1 Pa1 253

PA1 键。The PA1 key.

Packet Packet Packet Packet 231

用于传递 Unicode 字符,如同它们是击键一样。Used to pass Unicode characters as if they were keystrokes. Packet 键值是用于非键盘输入法的 32 位虚拟键值的低位字。The Packet key value is the low word of a 32-bit virtual-key value used for non-keyboard input methods.

PageDown PageDown PageDown PageDown 34

PAGE DOWN 键。The PAGE DOWN key.

PageUp PageUp PageUp PageUp 33

PAGE UP 键。The PAGE UP key.

Pause Pause Pause Pause 19

PAUSE 键。The PAUSE key.

Play Play Play Play 250

播放键。The PLAY key.

Print Print Print Print 42

PRINT 键。The PRINT key.

PrintScreen PrintScreen PrintScreen PrintScreen 44

PRINT SCREEN 键。The PRINT SCREEN key.

Prior Prior Prior Prior 33

PAGE UP 键。The PAGE UP key.

ProcessKey ProcessKey ProcessKey ProcessKey 229

PROCESS KEY 键。The PROCESS KEY key.

Q Q Q Q 81

Q 键。The Q key.

R R R R 82

R 键。The R key.

RButton RButton RButton RButton 2

鼠标右按钮。The right mouse button.

RControlKey RControlKey RControlKey RControlKey 163

右 CTRL 键。The right CTRL key.

Return Return Return Return 13

RETURN 键。The RETURN key.

Right Right Right Right 39

RIGHT ARROW 键。The RIGHT ARROW key.

RMenu RMenu RMenu RMenu 165

右 ALT 键。The right ALT key.

RShiftKey RShiftKey RShiftKey RShiftKey 161

右 SHIFT 键。The right SHIFT key.

RWin RWin RWin RWin 92

右 Windows 徽标键 (Microsoft Natural Keyboard)。The right Windows logo key (Microsoft Natural Keyboard).

S S S S 83

S 键。The S key.

Scroll Scroll Scroll Scroll 145

SCROLL LOCK 键。The SCROLL LOCK key.

Select Select Select Select 41

SELECT 键。The SELECT key.

SelectMedia SelectMedia SelectMedia SelectMedia 181

选择媒体键 (Windows 2000 或更高版本) 中。The select media key (Windows 2000 or later).

Separator Separator Separator Separator 108

分隔符键。The separator key.

Shift Shift Shift Shift 65536

SHIFT 修改键。The SHIFT modifier key.

ShiftKey ShiftKey ShiftKey ShiftKey 16

SHIFT 键。The SHIFT key.

Sleep Sleep Sleep Sleep 95

计算机休眠键。The computer sleep key.

Snapshot Snapshot Snapshot Snapshot 44

PRINT SCREEN 键。The PRINT SCREEN key.

Space Space Space Space 32

SPACEBAR 键。The SPACEBAR key.

Subtract Subtract Subtract Subtract 109

减号键。The subtract key.

T T T T 84

T 键。The T key.

Tab Tab Tab Tab 9

TAB 键。The TAB key.

U U U U 85

U 键。The U key.

Up Up Up Up 38

UP ARROW 键。The UP ARROW key.

V V V V 86

V 键。The V key.

VolumeDown VolumeDown VolumeDown VolumeDown 174

减小音量键 (Windows 2000 或更高版本)。The volume down key (Windows 2000 or later).

VolumeMute VolumeMute VolumeMute VolumeMute 173

静音键 (Windows 2000 或更高版本)。The volume mute key (Windows 2000 or later).

VolumeUp VolumeUp VolumeUp VolumeUp 175

增大音量键 (Windows 2000 或更高版本)。The volume up key (Windows 2000 or later).

W W W W 87

W 键。The W key.

X X X X 88

X 键。The X key.

XButton1 XButton1 XButton1 XButton1 5

第一个 x 鼠标按钮 (五个按钮的鼠标)。The first x mouse button (five-button mouse).

XButton2 XButton2 XButton2 XButton2 6

第二个 x 鼠标按钮 (五个按钮的鼠标)。The second x mouse button (five-button mouse).

Y Y Y Y 89

Y 键。The Y key.

Z Z Z Z 90

Z 键。The Z key.

Zoom Zoom Zoom Zoom 251

缩放键。The ZOOM key.

示例

下面的代码示例使用KeyDown事件来确定的字符输入到控件的类型。The following code example uses the KeyDown event to determine the type of character entered into the control.

   // Boolean flag used to determine when a character other than a number is entered.
private:
   bool nonNumberEntered;

   // Handle the KeyDown event to determine the type of character entered into the control.
   void textBox1_KeyDown( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
   {
      // Initialize the flag to false.
      nonNumberEntered = false;

      // Determine whether the keystroke is a number from the top of the keyboard.
      if ( e->KeyCode < Keys::D0 || e->KeyCode > Keys::D9 )
      {
         // Determine whether the keystroke is a number from the keypad.
         if ( e->KeyCode < Keys::NumPad0 || e->KeyCode > Keys::NumPad9 )
         {
            // Determine whether the keystroke is a backspace.
            if ( e->KeyCode != Keys::Back )
            {
               // A non-numerical keystroke was pressed.
               // Set the flag to true and evaluate in KeyPress event.
               nonNumberEntered = true;
            }
         }
      }
      //If shift key was pressed, it's not a number.
      if (Control::ModifierKeys == Keys::Shift) {
         nonNumberEntered = true;
      }
   }

   // This event occurs after the KeyDown event and can be used to prevent
   // characters from entering the control.
   void textBox1_KeyPress( Object^ /*sender*/, System::Windows::Forms::KeyPressEventArgs^ e )
   {
      // Check for the flag being set in the KeyDown event.
      if ( nonNumberEntered == true )
      {         // Stop the character from being entered into the control since it is non-numerical.
         e->Handled = true;
      }
   }
// Boolean flag used to determine when a character other than a number is entered.
private bool nonNumberEntered = false;

// Handle the KeyDown event to determine the type of character entered into the control.
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    // Initialize the flag to false.
    nonNumberEntered = false;

    // Determine whether the keystroke is a number from the top of the keyboard.
    if (e.KeyCode < Keys.D0 || e.KeyCode > Keys.D9)
    {
        // Determine whether the keystroke is a number from the keypad.
        if (e.KeyCode < Keys.NumPad0 || e.KeyCode > Keys.NumPad9)
        {
            // Determine whether the keystroke is a backspace.
            if(e.KeyCode != Keys.Back)
            {
                // A non-numerical keystroke was pressed.
                // Set the flag to true and evaluate in KeyPress event.
                nonNumberEntered = true;
            }
        }
    }
    //If shift key was pressed, it's not a number.
    if (Control.ModifierKeys == Keys.Shift) {
        nonNumberEntered = true;
    }
}

// This event occurs after the KeyDown event and can be used to prevent
// characters from entering the control.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
    // Check for the flag being set in the KeyDown event.
    if (nonNumberEntered == true)
    {
        // Stop the character from being entered into the control since it is non-numerical.
        e.Handled = true;
    }
}

' Boolean flag used to determine when a character other than a number is entered.
Private nonNumberEntered As Boolean = False


' Handle the KeyDown event to determine the type of character entered into the control.
Private Sub textBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) _
     Handles textBox1.KeyDown
    ' Initialize the flag to false.
    nonNumberEntered = False
  
    ' Determine whether the keystroke is a number from the top of the keyboard.
    If e.KeyCode < Keys.D0 OrElse e.KeyCode > Keys.D9 Then
        ' Determine whether the keystroke is a number from the keypad.
        If e.KeyCode < Keys.NumPad0 OrElse e.KeyCode > Keys.NumPad9 Then
            ' Determine whether the keystroke is a backspace.
            If e.KeyCode <> Keys.Back Then
                ' A non-numerical keystroke was pressed. 
                ' Set the flag to true and evaluate in KeyPress event.
                nonNumberEntered = True
            End If
        End If
    End If
    'If shift key was pressed, it's not a number.
    If Control.ModifierKeys = Keys.Shift Then
        nonNumberEntered = true
    End If
End Sub 'textBox1_KeyDown


' This event occurs after the KeyDown event and can be used 
' to prevent characters from entering the control.
Private Sub textBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) _
    Handles textBox1.KeyPress
    ' Check for the flag being set in the KeyDown event.
    If nonNumberEntered = True Then
        ' Stop the character from being entered into the control since it is non-numerical.
        e.Handled = True
    End If
End Sub 'textBox1_KeyPress

注解

Keys类包含用于处理键盘输入的常数。The Keys class contains constants for processing keyboard input. 键代码和修饰符合并到单个整数值的一组包含密钥枚举的成员。The members of the Keys enumeration consist of a key code and a set of modifiers combined into a single integer value. 在 Win32 应用程序编程接口 (API) 的密钥值都有两个部分,使用包含的键代码 (这是 Windows 的虚拟键代码相同),高序位和表示如 SHIFT、 控制和 ALT 键修饰符的低顺序位键。In the Win32 application programming interface (API) a key value has two halves, with the high-order bits containing the key code (which is the same as a Windows virtual key code), and the low-order bits representing key modifiers such as the SHIFT, CONTROL, and ALT keys.

警告

请组合的位运算中使用此枚举中值。Do not use the values in this enumeration for combined bitwise operations. 枚举中的值不是互斥的。The values in the enumeration are not mutually exclusive.

备注

此枚举提供方法来测试是否当前激活的 CAPS LOCK 或 NUM LOCK 键。This enumeration provides no way to test whether the CAPS LOCK or NUM LOCK keys are currently activated. 可以使用以下方法之一来确定这些键是否已激活:You can use one of the following techniques to determine if these keys are activated:

  • 调用 IsKeyLocked 类的 Control 方法。Call the IsKeyLocked method of the Control class.

  • 对于更精细的控制,使用 Windows API 函数GetKeyStateGetAsyncKeyState,或GetKeyboardStateuser32.dll,若要执行此操作中定义。For finer control, use the Windows API functions GetKeyState, GetAsyncKeyState, or GetKeyboardState defined in user32.dll, to do this. 调用本机函数的详细信息,请参阅使用非托管 DLL 函数For more information about calling native functions, see Consuming Unmanaged DLL Functions.

下表显示了表示两个枚举值,该值表示常规原始设备制造商 (OEM) 密钥和更具体的美式键盘关联的键代码值。The following table shows the key code values represented by two enumerated values, representing both the general original equipment manufacturer (OEM) keys and the more specific U.S.-keyboard associations.

十六进制值Hexadecimal value 美式键盘U.S. keyboard 常规 OEMGeneral OEM
BABA OemSemicolonOemSemicolon Oem1Oem1
BFBF OemQuestionOemQuestion Oem2Oem2
C0C0 OemtildeOemtilde Oem3Oem3
DBDB OemOpenBracketsOemOpenBrackets Oem4Oem4
DCDC OemPipeOemPipe Oem5Oem5
DDDD OemCloseBracketsOemCloseBrackets Oem6Oem6
DEDE OemQuotesOemQuotes Oem7Oem7
E2E2 OemBackslashOemBackslash Oem102Oem102

注意

为.NET Framework 2.0 中,成员 IMEAccept 已添加,取代了以前的条目,IMEAceept,存在拼写错误。For the .NET Framework 2.0, a member IMEAccept was added that supersedes the previous entry, IMEAceept, which was spelled incorrectly. 已保留的较旧版本向后兼容,但它可能在.NET Framework 的未来版本中删除The older version has been retained for backward compatibility, but it may be deleted in future versions of the .NET Framework

适用于

另请参阅