|
Answer» In qbasic 1.1, when I use an ON KEY for the arrow keys, for example: Code: [Select]... ON KEY(11) GOSUB up KEY(11) ON ... DO WHILE INKEY$ <> CHR$(27) 'Esc LOCATE 1,1: PRINT response LOCATE y,X: PRINT "*" 'qbasic, with the locate command, uses rows before column thus y,x LOOP END ... up: y = y - 1 Response = "up" GOSUB checkxy RETURN ... checkxy: If x > 23 THEN x = 23 IF x < 1 THEN x = 1 IF y > 79 THEN y = 79 IF y < 10 THEN y = 10 RETURN When I press the up arow, it moves the asterisk up one row, waits for half a SECOND, and then the asterisk moves again, continuously up rows. How MIGHT I CHANGE this so that when I press and hold the up arrow it just moves my asterisk without the delay?
This has been a problem across Qbasic and VB.net for me for a while with different programs, and I've never worked it out...
Thanks, BonesI found a solution for vb, actually, but not one for qbasic. Here's the vb one, as sourced from experts-exchange, http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20654594.html?sfQueryTermInfo=1+repeat
Code: [Select]General Declarations: dim x as integer dim y as integer
Sub Form_KeyDown (keycode As Integer, Shift As Integer) Select Case (keycode)
Case 37 keyleft = 1
Case 39 keyup = 1
Case 38 keyright = 1
Case 40 keydown = 1
End Select
End Sub
Sub Form_KeyUp (keycode As Integer, Shift As Integer) Select Case (keycode)
Case 37 keyleft = 0
Case 39 keyup = 0
Case 38 keyright = 0
Case 40 keydown = 0
End Select
End Sub
Sub Timer1_Timer ()
If keyright=1 then x=x+1 If keyleft=1 then x=x-1 If keyup=1 then y=y+1 If keyright=1 then y=y-1
End Sub
This isn't terribly helpful for use with qbasic.... and incase anyones wondering why i'm using qbasic, its because my palmtop has MS-DOS 5.0 on it,
|