The two key event argument classes KeyEventArgs and PreviewKeyDownEventArgs each have two properties, KeyCode and KeyData, which are both of the enumeration type Keys.
What is the difference between these two properties? Do the values in them ever differ from each other? If so, when and why?
KeyCodeis an enumeration that represents all the possible keys on the keyboard.KeyDatais theKeyCodecombined with the modifiers (Ctrl, Alt and/or Shift).Use
KeyCodewhen you don’t care about the modifiers,KeyDatawhen you do.