Home > Geek Tips > Virtual Key Constants in C#

Virtual Key Constants in C#

I ran into another issue searching for virtual key constants on google. In VB6 you can reference virtual keys by using the vbKey constants (i.e, vbKeyF4, vbKeyShift). I knew there had to be a way to do this in the .Net framework without defining the constants yourself (VK_SHIFT, VK_CAPITAL), I just couldn’t find it. Luckily, I had a friend who knew the answer to this, because google came up short this time.

In order to reference virtual keys in the framework, use the static object “Keys” in the System.Windows.Forms namespace (i.e, System.Windows.Forms.Keys.Capital).

Categories: Geek Tips Tags:
  1. No comments yet.
  1. No trackbacks yet.

Spam protection by WP Captcha-Free