That's a really nice reference and + 1 for possting it, but...
That really doesn't trap the SHIFT key. In fact, don't press SHIFT and the values are exactly the same. So how can we see if either the Right SHIFT or Left SHIFT key is being held using INKEY$, or just see if SHIFT, ALT or CTRL are pressed alone or in combo? Like this...
Now PEEK and POKE stuff is said to be deprecated, but I guess to preserve backwoods compatibility, they remain in use for some, but not all, of the ways they could be applied under QuickBASIC .
I love INKEY$ but it does have some problems detecting key up and down status. You would think by polling R$ = INKEY$: IF LEN(R$) THEN the key is down, but no. You can write a little sample code for yourself, hold some damn key down, hell, have an elephant sit on it, and you will find several instances in the cycle where the key is reported up, even though it was never released! This sucks big time and the only good way around it is to convert to the QB64 _KEYHIT and the up and down keywords associated with that keyboard INKEY$ replacement series. Oh, there is a Mickey Mouse method with INKEY$ that can be added, which I did include in this example using TIMER and the variable oldb$.
Now if you will excuse me, I have to hire Clippy to lean the elephant **** off my F12 key. I hear he works for peanuts!
Pete
Code: (Select All)
Const KeyShiftDel = Chr$(0) + Chr$(83)
Const KeyShiftDown = Chr$(0) + Chr$(80)
Const KeyShiftEnd = Chr$(0) + Chr$(79)
Const KeyShiftIns = Chr$(0) + Chr$(82)
Const KeyShiftLeft = Chr$(0) + Chr$(75)
Const KeyShiftPgDown = Chr$(0) + Chr$(81)
Const KeyShiftPgUp = Chr$(0) + Chr$(73)
Const KeyShiftRight = Chr$(0) + Chr$(77)
Const KeyShiftUp = Chr$(0) + Chr$(72)
That really doesn't trap the SHIFT key. In fact, don't press SHIFT and the values are exactly the same. So how can we see if either the Right SHIFT or Left SHIFT key is being held using INKEY$, or just see if SHIFT, ALT or CTRL are pressed alone or in combo? Like this...
Code: (Select All)
Do
_Limit 30
Def Seg = 0
i% = Peek(1047) Mod 16
Def Seg
b$ = InKey$
Locate 1, 1
If i% Then j% = 0
Select Case i%
Case 1: Print "Right Shift "
Case 2: Print "Left Shift "
Case 4: Print "Ctrl "
Case 5: Print "Right Shift + Ctrl "
Case 6: Print "Left Shift + Ctrl "
Case 8: Print "Alt "
Case 9: Print "Right Shift + Alt "
Case 10: Print "Left Shift + Alt "
Case 12: Print "Ctrl + Alt "
Case 13: Print "Right Shift + Ctrl + Alt"
Case 14: Print "Left Shift + Ctrl + Alt "
End Select
If Len(b$) Then
If i% = 0 Then Print Space$(24)
Locate 2, 1
End If
Select Case Len(b$)
Case 0
If Len(oldb$) Then
If Abs(z1! - Timer) > .1 Then
Locate 3, 1: Print "F12 was released. "
oldb$ = ""
End If
End If
Case 1: Print Asc(b$, 1); " ";: j% = 0
Case 2
Print "CHR$(0) +"; Asc(b$, 2); " ";
j% = Asc(Right$(b$, 1)) ' For F12 key.
If j% = 134 Then
z1! = Timer
If oldb$ <> b$ Then
Locate 3, 1: Print "F12 was pressed. "
oldb$ = b$
Sleep 1 ' Needed to prevent double entry.
Else
_Continue
End If
End If
End Select
If j% <> 134 Then Locate 3, 1: Print Space$(25);
Loop Until b$ = Chr$(27) ' End on Esc.
Now PEEK and POKE stuff is said to be deprecated, but I guess to preserve backwoods compatibility, they remain in use for some, but not all, of the ways they could be applied under QuickBASIC .
I love INKEY$ but it does have some problems detecting key up and down status. You would think by polling R$ = INKEY$: IF LEN(R$) THEN the key is down, but no. You can write a little sample code for yourself, hold some damn key down, hell, have an elephant sit on it, and you will find several instances in the cycle where the key is reported up, even though it was never released! This sucks big time and the only good way around it is to convert to the QB64 _KEYHIT and the up and down keywords associated with that keyboard INKEY$ replacement series. Oh, there is a Mickey Mouse method with INKEY$ that can be added, which I did include in this example using TIMER and the variable oldb$.
Now if you will excuse me, I have to hire Clippy to lean the elephant **** off my F12 key. I hear he works for peanuts!
Pete
Shoot first and shoot people who ask questions, later.