Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: beginner
Dec 23, 2002



Application Security Testing: An Integral Part of DevOps

Retrieving the state of the Shift, Alt and Ctrl keys, at any time

You can know the state of the Shift, Alt and Control keys at any time, not just from inside a Keyxxx event. The shared property Control.ModifierKeys returns a bit coded value that identifies which of those keys are pressed, and you can use the And bit operator if a specific key is pressed. The following code shows an example:

Dim isShiftPressed As Boolean = (Control.ModifierKeys And Keys.Shift) <> 0
Dim isAltPressed As Boolean = (Control.ModifierKeys And Keys.Alt) <> 0
Dim isControlPressed As Boolean = (Control.ModifierKeys And Keys.Control) <> 0

MessageBox.Show("Shift pressed: " & isShiftPressed & Environment.NewLine & _
    "Alt pressed:" & isAltPressed & Environment.NewLine & "Control pressed:" & _
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date