|
|
The KeyMasks can be obtained by performing a check against the applicable key masks. Often the key masks are hard to remember. Pass your boolean variables ByRef to this function and get a return for each Shift, Ctrl or Alt key status/ CODE ' Code courtesy of UtterAccess Wiki ' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' REV DATE DESCRIPTION ' 1.0 2010-08-06 initial release ' 1.1 2010-09-12 changed header '============================================================================== ' NAME: GetKeyMasks ' PURPOSE: returns boolean to deterimine if the Shift Ctrl or Alt key is down ' RETURNS: None (byref args) '============================================================================== 'ErrHandler V3.01 Public Function GetKeyMasks( _ ByVal iShift As Integer, _ Optional ByRef bShift As Boolean = False, _ Optional ByRef bCtrl As Boolean = False, _ Optional ByRef bAlt As Boolean = False) On Error GoTo Error_Proc '========================= '========================= bShift = (iShift And acShiftMask) <> 0 bCtrl = (iShift And acCtrlMask) <> 0 bAlt = (iShift And acAltMask) <> 0 '========================= Exit_Proc: Exit Function Error_Proc: Select Case Err.Number Case Else MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _ "Desc: " & Err.Description & vbCrLf & vbCrLf & _ "Procedure: GetKeyMasks" _ , vbCritical, "Error!" End Select Resume Exit_Proc Resume End Function
|
| This page was last modified 08:34, 6 April 2011. This page has been accessed 1,006 times. Disclaimers |