A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Try this one.
Andreas.
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Long
Function ShiftPressed() As Boolean
'True wenn die Shift-Taste gedrückt ist
Const VK_SHIFT = &H10 ' Shift Taste
ShiftPressed = GetAsyncKeyState(VK_SHIFT) And &H8000 <> 0
End Function
Function CtrlPressed() As Boolean
'True wenn die Strg-Taste gedrückt ist
Const VK_CONTROL = &H11 ' STRG Taste
CtrlPressed = GetAsyncKeyState(VK_CONTROL) And &H8000 <> 0
End Function
Function AltPressed() As Boolean
'True wenn die Alt-Taste gedrückt ist
Const VK_MENU = &H12 ' Alt Taste
AltPressed = GetAsyncKeyState(VK_MENU) And &H8000 <> 0
End Function
Function KeyPressed() As Boolean
'True wenn eine Taste gedrückt ist
Dim Cnt As Long
For Cnt = 1 To 128
If GetAsyncKeyState(Cnt) And &H8000 <> 0 Then
KeyPressed = True
Exit Function
End If
Next
End Function
Function ShiftWasPressed() As Boolean
'True wenn die Shift-Taste gedrückt wurde (seit dem letzen Aufruf)
Const VK_SHIFT = &H10 ' Shift Taste
ShiftWasPressed = GetAsyncKeyState(VK_SHIFT) And 1 <> 0
End Function
Function CtrlWasPressed() As Boolean
'True wenn die Strg-Taste gedrückt wurde (seit dem letzen Aufruf)
Const VK_CONTROL = &H11 ' STRG Taste
CtrlWasPressed = GetAsyncKeyState(VK_CONTROL) And 1 <> 0
End Function
Function AltWasPressed() As Boolean
'True wenn die Alt-Taste gedrückt ist
Const VK_MENU = &H12 ' Alt Taste
AltWasPressed = GetAsyncKeyState(VK_MENU) And 1 <> 0
End Function
Function KeyWasPressed() As Boolean
'True wenn eine Taste gedrückt ist
Dim Cnt As Long
For Cnt = 1 To 128
If GetAsyncKeyState(Cnt) And 1 <> 0 Then
KeyWasPressed = True
Exit Function
End If
Next
End Function