There is a way to detect how long a key is pressed?
Posted: Fri Mar 08, 2019 2:11 pm
A keyboard key or a mouse key.
thanks
thanks
The Cross-Platform Multimedia Application Layer
https://forums.hollywood-mal.com/
Code: Select all
EscapeQuit(True)
StartTimer(1)
Repeat
If IsLeftMouse() = True
ResetTimer(1)
endloop=False
Repeat
If IsLeftMouse() = False Then endloop=True
Until endloop=True
timeittook = GetTimer(1)
DebugPrint("left mouse button was down for "..timeittook.." milliseconds")
EndIf
Forever
Code: Select all
Function p_Input(msg)
Switch msg.Action
Case "OnMouseDown":
StartTimer(1)
Case "OnMouseUp":
DebugPrint("Mouse was pressed for " .. GetTimer(1) .. " milliseconds.")
StopTimer(1)
Case "OnKeyDown":
StartTimer(2)
Case "OnKeyUp":
DebugPrint("A key was pressed for " .. GetTimer(2) .. " milliseconds.")
StopTimer(2)
EndSwitch
EndFunction
EscapeQuit(True)
InstallEventHandler({OnMouseDown = p_Input, OnMouseUp = p_Input, OnKeyDown = p_Input, OnKeyUp = p_Input})
Repeat
WaitEvent
Forever