Post by TJ on Mar 16, 2022 15:43:31 GMT -5
I am using this code as an example of the keyboard function's and need help getting the number keys ( 1 through 9 )to work .
I have the F 1 keys and arrow keys reading along with the space bar and E S C key . No luck so far with the number keys .
This is my example I have made , as you can see my two lines that use the number keys are off ' ' This is the line I am trying to add using 1 to 9 keys
I think it is some where in my open "KeyBoard" for graphics as #Key
My actual program goes in a robot that use's arduino and several relays and that why I need the numbers to work
Thanks
Tom
I have the F 1 keys and arrow keys reading along with the space bar and E S C key . No luck so far with the number keys .
This is my example I have made , as you can see my two lines that use the number keys are off ' ' This is the line I am trying to add using 1 to 9 keys
I think it is some where in my open "KeyBoard" for graphics as #Key
My actual program goes in a robot that use's arduino and several relays and that why I need the numbers to work
Thanks
Tom
UpperLeftX = 800
UpperLeftY = 50
WindowWidth = 400
WindowHeight = 200
textbox #Key.selectedField1, 10, 20, 300, 30
textbox #Key.selectedField2, 10, 70, 300, 30
open "KeyBoard" for graphics as #Key
#Key "down" 'put the pen down
#Key "trapclose [quitX]"
print #Key, "fill darkgray; flush"
print #Key, "font cooper_black 16"
timer 100
[loop1]
print #Key.selectedField2, "Esc pressed End "
if keyState(_VK_F1) then gosub [F1]
if keyState(_VK_F2) then gosub [F2]
'if keyState(_VK_1) then gosub [1] 'This is the line Iam trying to add using 1 to 9 keys
if keyState(_VK_LEFT) then gosub [Left]
if keyState(_VK_RIGHT) then gosub [Right]
if keyState(_VK_UP) then gosub [Up]
if keyState(_VK_DOWN) then gosub [Dn]
if keyState(32) then gosub [1off]
if keyState(27) then print "Esc pressed.Ended.":goto [quitX]
goto [loop1]
function keyState(keycode)
calldll #user32, "GetAsyncKeyState", _ '
keycode AS long, _
state AS long
if state <> 0 then keyState = 1 ' 1= pressed
end function
[Left]
print #Key.selectedField1, "Left Arrow Key "
return
[Right] '"Down is pressed \/
print #Key.selectedField1, "Right Arrow Key "
return
[Up]
print #Key.selectedField1, "Up Key "
return
[Dn]
print #Key.selectedField1, "Down Key "
return
[F1]
print #Key.selectedField1, "F1 Key "
return
[F2]
print #Key.selectedField1, "F2 Key "
return
[1]
print #Key.selectedField1, "1 Key " 'This is the line Iam trying to add using 1 to 9 keys
return
[1off] '"Space is pressed__
print #Key.selectedField1, " "
return
[quitX]
close #Key
end