I have question about the KeyEventArgs's KeyCode and KeyData and KeyValue.
KeyCode and Keydata are Keys type, but I don't know what the difference between them is. For KeyValue, I don't know what it is -- it has an int type, does it return the char value of the pressed key?
I don't have much experience with Key events; any explanation of how they function and how to use them would be greatly appreciated.
KeyCodecontains data for the key that produced theKeyUporKeyDownevent.KeyDatacontains the combination of that key together with CTRL, SHIFT or ALT if any of those were pressed.Example:
KeyDownwill be raised,KeyCodewill beKeys.ControlKey,KeyDatawill beKeys.ControlKey | Keys.Control.KeyDownwill be raised,KeyCodewill beKeys.ShiftKeyandKeyDatawill beKeys.ShifKey | Keys.Shift | Keys.Control.Note that
KeyDataandKeyCodecan contain any value in theKeysenumeration (such asKeys.A,Keys.NumPad4orKeys.Up). Note that when one of the modifier keys are pressed, it is represented by two values inKeyData(one for they key and one for the modifier value). The modifiers are also available through theModifiersproperty.KeyValuewill return a numerical value representing the key, essentially an integer representing the value found inKeyCode.