KeyEventArgs.KeyData, KeyEventArgs.KeyCode and KeyEventArgs.KeyValue

左心房为你撑大大i 提交于 2019-12-03 02:41:20

KeyCode contains data for the key that produced the KeyUp or KeyDown event. KeyData contains the combination of that key together with CTRL, SHIFT or ALT if any of those were pressed.

Example:

  • Press (and hold) CTRL. KeyDown will be raised, KeyCode will be Keys.ControlKey, KeyData will be Keys.ControlKey | Keys.Control.
  • While still holding CTRL pressed, press SHIFT. KeyDown will be raised, KeyCode will be Keys.ShiftKey and KeyData will be Keys.ShifKey | Keys.Shift | Keys.Control.

Note that KeyData and KeyCode can contain any value in the Keys enumeration (such as Keys.A, Keys.NumPad4 or Keys.Up). Note that when one of the modifier keys are pressed, it is represented by two values in KeyData (one for they key and one for the modifier value). The modifiers are also available through the Modifiers property.

KeyValue will return a numerical value representing the key, essentially an integer representing the value found in KeyCode.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!