블로그 보관함

2012년 4월 22일 일요일

C# 키코드


Member name
Description
Value
A
Supported by the .NET Compact Framework.
The A key.
65
Add
Supported by the .NET Compact Framework.
The add key.
107
Alt
Supported by the .NET Compact Framework.
The ALT modifier key.
262144
Apps
Supported by the .NET Compact Framework.
The application key (Microsoft Natural Keyboard).
93
Attn
Supported by the .NET Compact Framework.
The ATTN key.
246
B
Supported by the .NET Compact Framework.
The B key.
66
Back
Supported by the .NET Compact Framework.
The BACKSPACE key.
8
BrowserBack
The browser back key (Windows 2000 or later).
166
BrowserFavorites
The browser favorites key (Windows 2000 or later).
171
BrowserForward
The browser forward key (Windows 2000 or later).
167
BrowserHome
The browser home key (Windows 2000 or later).
172
BrowserRefresh
The browser refresh key (Windows 2000 or later).
168
BrowserSearch
The browser search key (Windows 2000 or later).
170
BrowserStop
The browser stop key (Windows 2000 or later).
169
C
Supported by the .NET Compact Framework.
The C key.
67
Cancel
Supported by the .NET Compact Framework.
The CANCEL key.
3
Capital
Supported by the .NET Compact Framework.
The CAPS LOCK key.
20
CapsLock
Supported by the .NET Compact Framework.
The CAPS LOCK key.
20
Clear
Supported by the .NET Compact Framework.
The CLEAR key.
12
Control
Supported by the .NET Compact Framework.
The CTRL modifier key.
131072
ControlKey
Supported by the .NET Compact Framework.
The CTRL key.
17
Crsel
Supported by the .NET Compact Framework.
The CRSEL key.
247
D
Supported by the .NET Compact Framework.
The D key.
68
D0
Supported by the .NET Compact Framework.
The 0 key.
48
D1
Supported by the .NET Compact Framework.
The 1 key.
49
D2
Supported by the .NET Compact Framework.
The 2 key.
50
D3
Supported by the .NET Compact Framework.
The 3 key.
51
D4
Supported by the .NET Compact Framework.
The 4 key.
52
D5
Supported by the .NET Compact Framework.
The 5 key.
53
D6
Supported by the .NET Compact Framework.
The 6 key.
54
D7
Supported by the .NET Compact Framework.
The 7 key.
55
D8
Supported by the .NET Compact Framework.
The 8 key.
56
D9
Supported by the .NET Compact Framework.
The 9 key.
57
Decimal
Supported by the .NET Compact Framework.
The decimal key.
110
Delete
Supported by the .NET Compact Framework.
The DEL key.
46
Divide
Supported by the .NET Compact Framework.
The divide key.
111
Down
Supported by the .NET Compact Framework.
The DOWN ARROW key.
40
E
Supported by the .NET Compact Framework.
The E key.
69
End
Supported by the .NET Compact Framework.
The END key.
35
Enter
Supported by the .NET Compact Framework.
The ENTER key.
13
EraseEof
Supported by the .NET Compact Framework.
The ERASE EOF key.
249
Escape
Supported by the .NET Compact Framework.
The ESC key.
27
Execute
Supported by the .NET Compact Framework.
The EXECUTE key.
43
Exsel
Supported by the .NET Compact Framework.
The EXSEL key.
248
F
Supported by the .NET Compact Framework.
The F key.
70
F1
Supported by the .NET Compact Framework.
The F1 key.
112
F10
Supported by the .NET Compact Framework.
The F10 key.
121
F11
Supported by the .NET Compact Framework.
The F11 key.
122
F12
Supported by the .NET Compact Framework.
The F12 key.
123
F13
Supported by the .NET Compact Framework.
The F13 key.
124
F14
Supported by the .NET Compact Framework.
The F14 key.
125
F15
Supported by the .NET Compact Framework.
The F15 key.
126
F16
Supported by the .NET Compact Framework.
The F16 key.
127
F17
Supported by the .NET Compact Framework.
The F17 key.
128
F18
Supported by the .NET Compact Framework.
The F18 key.
129
F19
Supported by the .NET Compact Framework.
The F19 key.
130
F2
Supported by the .NET Compact Framework.
The F2 key.
113
F20
Supported by the .NET Compact Framework.
The F20 key.
131
F21
Supported by the .NET Compact Framework.
The F21 key.
132
F22
Supported by the .NET Compact Framework.
The F22 key.
133
F23
Supported by the .NET Compact Framework.
The F23 key.
134
F24
Supported by the .NET Compact Framework.
The F24 key.
135
F3
Supported by the .NET Compact Framework.
The F3 key.
114
F4
Supported by the .NET Compact Framework.
The F4 key.
115
F5
Supported by the .NET Compact Framework.
The F5 key.
116
F6
Supported by the .NET Compact Framework.
The F6 key.
117
F7
Supported by the .NET Compact Framework.
The F7 key.
118
F8
Supported by the .NET Compact Framework.
The F8 key.
119
F9
Supported by the .NET Compact Framework.
The F9 key.
120
FinalMode
The IME final mode key.
24
G
Supported by the .NET Compact Framework.
The G key.
71
H
Supported by the .NET Compact Framework.
The H key.
72
HanguelMode
The IME Hanguel mode key. (maintained for compatibility; use HangulMode)
21
HangulMode
The IME Hangul mode key.
21
HanjaMode
The IME Hanja mode key.
25
Help
Supported by the .NET Compact Framework.
The HELP key.
47
Home
Supported by the .NET Compact Framework.
The HOME key.
36
I
Supported by the .NET Compact Framework.
The I key.
73
IMEAceept
The IME accept key.
30
IMEConvert
The IME convert key.
28
IMEModeChange
The IME mode change key.
31
IMENonconvert
The IME nonconvert key.
29
Insert
Supported by the .NET Compact Framework.
The INS key.
45
J
Supported by the .NET Compact Framework.
The J key.
74
JunjaMode
The IME Junja mode key.
23
K
Supported by the .NET Compact Framework.
The K key.
75
KanaMode
The IME Kana mode key.
21
KanjiMode
The IME Kanji mode key.
25
KeyCode
Supported by the .NET Compact Framework.
The bitmask to extract a key code from a key value.
65535
L
Supported by the .NET Compact Framework.
The L key.
76
LaunchApplication1
The start application one key (Windows 2000 or later).
182
LaunchApplication2
The start application two key (Windows 2000 or later).
183
LaunchMail
The launch mail key (Windows 2000 or later).
180
LButton
Supported by the .NET Compact Framework.
The left mouse button.
1
LControlKey
Supported by the .NET Compact Framework.
The left CTRL key.
162
Left
Supported by the .NET Compact Framework.
The LEFT ARROW key.
37
LineFeed
Supported by the .NET Compact Framework.
The LINEFEED key.
10
LMenu
Supported by the .NET Compact Framework.
The left ALT key.
164
LShiftKey
Supported by the .NET Compact Framework.
The left SHIFT key.
160
LWin
Supported by the .NET Compact Framework.
The left Windows logo key (Microsoft Natural Keyboard).
91
M
Supported by the .NET Compact Framework.
The M key.
77
MButton
Supported by the .NET Compact Framework.
The middle mouse button (three-button mouse).
4
MediaNextTrack
The media next track key (Windows 2000 or later).
176
MediaPlayPause
The media play pause key (Windows 2000 or later).
179
MediaPreviousTrack
The media previous track key (Windows 2000 or later).
177
MediaStop
The media Stop key (Windows 2000 or later).
178
Menu
Supported by the .NET Compact Framework.
The ALT key.
18
Modifiers
Supported by the .NET Compact Framework.
The bitmask to extract modifiers from a key value.
-65536
Multiply
Supported by the .NET Compact Framework.
The multiply key.
106
N
Supported by the .NET Compact Framework.
The N key.
78
Next
Supported by the .NET Compact Framework.
The PAGE DOWN key.
34
NoName
Supported by the .NET Compact Framework.
A constant reserved for future use.
252
None
Supported by the .NET Compact Framework.
No key pressed.
0
NumLock
Supported by the .NET Compact Framework.
The NUM LOCK key.
144
NumPad0
Supported by the .NET Compact Framework.
The 0 key on the numeric keypad.
96
NumPad1
Supported by the .NET Compact Framework.
The 1 key on the numeric keypad.
97
NumPad2
Supported by the .NET Compact Framework.
The 2 key on the numeric keypad.
98
NumPad3
Supported by the .NET Compact Framework.
The 3 key on the numeric keypad.
99
NumPad4
Supported by the .NET Compact Framework.
The 4 key on the numeric keypad.
100
NumPad5
Supported by the .NET Compact Framework.
The 5 key on the numeric keypad.
101
NumPad6
Supported by the .NET Compact Framework.
The 6 key on the numeric keypad.
102
NumPad7
Supported by the .NET Compact Framework.
The 7 key on the numeric keypad.
103
NumPad8
Supported by the .NET Compact Framework.
The 8 key on the numeric keypad.
104
NumPad9
Supported by the .NET Compact Framework.
The 9 key on the numeric keypad.
105
O
Supported by the .NET Compact Framework.
The O key.
79
Oem8
OEM specific.
223
OemBackslash
The OEM angle bracket or backslash key on the RT 102 key keyboard (Windows 2000 or later).
226
OemClear
Supported by the .NET Compact Framework.
The CLEAR key.
254
OemCloseBrackets
The OEM close bracket key on a US standard keyboard (Windows 2000 or later).
221
Oemcomma
The OEM comma key on any country/region keyboard (Windows 2000 or later).
188
OemMinus
The OEM minus key on any country/region keyboard (Windows 2000 or later).
189
OemOpenBrackets
The OEM open bracket key on a US standard keyboard (Windows 2000 or later).
219
OemPeriod
The OEM period key on any country/region keyboard (Windows 2000 or later).
190
OemPipe
The OEM pipe key on a US standard keyboard (Windows 2000 or later).
220
Oemplus
The OEM plus key on any country/region keyboard (Windows 2000 or later).
187
OemQuestion
The OEM question mark key on a US standard keyboard (Windows 2000 or later).
191
OemQuotes
The OEM singled/double quote key on a US standard keyboard (Windows 2000 or later).
222
OemSemicolon
The OEM semicolon key on a US standard keyboard (Windows 2000 or later).
186
Oemtilde
The OEM tilde key on a US standard keyboard (Windows 2000 or later).
192
P
Supported by the .NET Compact Framework.
The P key.
80
Pa1
Supported by the .NET Compact Framework.
The PA1 key.
253
PageDown
Supported by the .NET Compact Framework.
The PAGE DOWN key.
34
PageUp
Supported by the .NET Compact Framework.
The PAGE UP key.
33
Pause
Supported by the .NET Compact Framework.
The PAUSE key.
19
Play
Supported by the .NET Compact Framework.
The PLAY key.
250
Print
Supported by the .NET Compact Framework.
The PRINT key.
42
PrintScreen
Supported by the .NET Compact Framework.
The PRINT SCREEN key.
44
Prior
Supported by the .NET Compact Framework.
The PAGE UP key.
33
ProcessKey
Supported by the .NET Compact Framework.
The PROCESS KEY key.
229
Q
Supported by the .NET Compact Framework.
The Q key.
81
R
Supported by the .NET Compact Framework.
The R key.
82
RButton
Supported by the .NET Compact Framework.
The right mouse button.
2
RControlKey
Supported by the .NET Compact Framework.
The right CTRL key.
163
Return
Supported by the .NET Compact Framework.
The RETURN key.
13
Right
Supported by the .NET Compact Framework.
The RIGHT ARROW key.
39
RMenu
Supported by the .NET Compact Framework.
The right ALT key.
165
RShiftKey
Supported by the .NET Compact Framework.
The right SHIFT key.
161
RWin
Supported by the .NET Compact Framework.
The right Windows logo key (Microsoft Natural Keyboard).
92
S
Supported by the .NET Compact Framework.
The S key.
83
Scroll
Supported by the .NET Compact Framework.
The SCROLL LOCK key.
145
Select
Supported by the .NET Compact Framework.
The SELECT key.
41
SelectMedia
The select media key (Windows 2000 or later).
181
Separator
Supported by the .NET Compact Framework.
The separator key.
108
Shift
Supported by the .NET Compact Framework.
The SHIFT modifier key.
65536
ShiftKey
Supported by the .NET Compact Framework.
The SHIFT key.
16
Snapshot
Supported by the .NET Compact Framework.
The PRINT SCREEN key.
44
Space
Supported by the .NET Compact Framework.
The SPACEBAR key.
32
Subtract
Supported by the .NET Compact Framework.
The subtract key.
109
T
Supported by the .NET Compact Framework.
The T key.
84
Tab
Supported by the .NET Compact Framework.
The TAB key.
9
U
Supported by the .NET Compact Framework.
The U key.
85
Up
Supported by the .NET Compact Framework.
The UP ARROW key.
38
V
Supported by the .NET Compact Framework.
The V key.
86
VolumeDown
The volume down key (Windows 2000 or later).
174
VolumeMute
The volume mute key (Windows 2000 or later).
173
VolumeUp
The volume up key (Windows 2000 or later).
175
W
Supported by the .NET Compact Framework.
The W key.
87
X
Supported by the .NET Compact Framework.
The X key.
88
XButton1
Supported by the .NET Compact Framework.
The first x mouse button (five-button mouse).
5
XButton2
Supported by the .NET Compact Framework.
The second x mouse button (five-button mouse).
6
Y
Supported by the .NET Compact Framework.
The Y key.
89
Z
Supported by the .NET Compact Framework.
The Z key.
90
Zoom
Supported by the .NET Compact Framework.
The ZOOM key.
251

사용예

 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;
            }
        }
    }
}