11-23-2022, 02:37 AM
Phil
Add this line, Locate 10, 10: Print n:n = n + 1,
Then run it
Then move the _Limit 30 to be before the GetAnAction: label and run it again to see the difference.
_KeyClear
Print "hit a key"
GetAnAction:
_Limit 30 ' limit resource usage
k = _KeyHit ' get code of key press
Locate 12, 40: Print k; Space$(15) ' erase previous key code
'###
Locate 10, 10: Print n:n = n + 1
'####
If k < 1 Then GoTo GetAnAction ' if there are no keys pressed, have another look - but only do this max 30 times per second
Locate 13, 1: Print Space$(20); ' erase previous key code announcement
Locate 13, 1
Print "ok, saw"; k ' announce key that was recognized
GoTo GetAnAction ' look for another key press
Add this line, Locate 10, 10: Print n:n = n + 1,
Then run it
Then move the _Limit 30 to be before the GetAnAction: label and run it again to see the difference.
_KeyClear
Print "hit a key"
GetAnAction:
_Limit 30 ' limit resource usage
k = _KeyHit ' get code of key press
Locate 12, 40: Print k; Space$(15) ' erase previous key code
'###
Locate 10, 10: Print n:n = n + 1
'####
If k < 1 Then GoTo GetAnAction ' if there are no keys pressed, have another look - but only do this max 30 times per second
Locate 13, 1: Print Space$(20); ' erase previous key code announcement
Locate 13, 1
Print "ok, saw"; k ' announce key that was recognized
GoTo GetAnAction ' look for another key press