Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any other way to ignore the Alt key using the INKEY method?
#21
Neat to see different approaches.

b$ = Chr$(kp - 96) ' Ctrl A-Z
b$ = Chr$(0) + Chr$(kp \ 256 + 35) ' Ctrl F1 - F10

You got the same results with
k = k Mod 32 ' Ctrl A-Z
k = k + 8960 ' Ctrl F1 - F10

For others it's a lot harder for me to see any connections like...

            Case 19200 '                            Arrow Lt
                b$ = Chr$(0) + Chr$(115)
            Case 19712 '                            Arrow Rt
                b$ = Chr$(0) + Chr$(116)
            Case 20224 '                            End
                b$ = Chr$(0) + Chr$(117)
            Case 20736 '                            PgDn
                b$ = Chr$(0) + Chr$(118)
            Case 18176 '                            Home
                b$ = Chr$(0) + Chr$(119)

So we are increasing by 512 until we get to the Home key, where we drop 1024 below the arrow left value. The increments are all multiples of 256 but what kind of math do you have to be doing to make this pattern apply to the Home key?

And, of course, the two other arrow keys seem closer to the _keyhit values for the other keys, but they are 140's for inkey values. That is a ratio that larger, so some interesting math is hiding there, too.

Pete
Reply
#22
(12-31-2025, 02:30 AM)Pete Wrote: b$ = Chr$(kp - 96) ' Ctrl A-Z
k = k Mod 32 ' Ctrl A-Z

Note that the above aren't the same.

In the case that you're dealing with CTRL a - z, they are.  But if caps lock is ON, then they aren't.

A is 65.
a is 97.

97 - 96 = 1  (so "a" works.)
65 - 96 = Your PC melted.   ("A" will fail.)

The mod method works in both cases.

65 mod 32 = 1
97 mod 32 = 1

Be careful with such things, unless you like melting your computer.  Wink
Reply
#23
Correct, but we are talking about using Ctrl in combo here, so caps on or off makes no difference. Hmm, I'll have to check the Alt key. Wink

Edit: Cap keys checked out, but apparently for Ctrl it registers the same with cap keys on as with lowercase, but when Shift is used Shift+Ctrl+(Letter) it registers uppercase, which does need the MOD 32 method after all. Nice!!!

Yep, I needed to add the -32 in the cases for Alt...

Code: (Select All)

Case 65, 97: b$ = Chr$(0) + Chr$(30) '    A - Z
Case 66, 98: b$ = Chr$(0) + Chr$(48)
Case 67, 99: b$ = Chr$(0) + Chr$(46)
Case 68, 100: b$ = Chr$(0) + Chr$(32)
Case 69, 101: b$ = Chr$(0) + Chr$(18)
Case 70, 102: b$ = Chr$(0) + Chr$(33)
Case 71, 103: b$ = Chr$(0) + Chr$(34)
Case 72, 104: b$ = Chr$(0) + Chr$(35)
Case 73, 105: b$ = Chr$(0) + Chr$(23)
Case 74, 106: b$ = Chr$(0) + Chr$(36)
Case 75, 107: b$ = Chr$(0) + Chr$(37)
Case 76, 108: b$ = Chr$(0) + Chr$(38)
Case 77, 109: b$ = Chr$(0) + Chr$(50)
Case 78, 110: b$ = Chr$(0) + Chr$(49)
Case 79, 111: b$ = Chr$(0) + Chr$(24)
Case 80, 112: b$ = Chr$(0) + Chr$(25)
Case 81, 113: b$ = Chr$(0) + Chr$(16)
Case 82, 114: b$ = Chr$(0) + Chr$(19)
Case 83, 115: b$ = Chr$(0) + Chr$(31)
Case 84, 116: b$ = Chr$(0) + Chr$(20)
Case 85, 117: b$ = Chr$(0) + Chr$(22)
Case 86, 118: b$ = Chr$(0) + Chr$(47)
Case 87, 119: b$ = Chr$(0) + Chr$(17)
Case 88, 120: b$ = Chr$(0) + Chr$(45)
Case 89, 121: b$ = Chr$(0) + Chr$(21)
Case 90, 122: b$ = Chr$(0) + Chr$(44)

Pete
Reply
#24
I feel like this is simple:

Code: (Select All)
Do
    _Limit 30
    x = _KeyHit
    If x Then
        If _KeyDown(100308) Or _KeyDown(100307) Then
            If (x - 32) >= 65 And (x - 32) <= 90 Then
                Print Chr$(x - 32)
            End If
        End If
    End If
Loop
The noticing will continue
Reply
#25
(12-31-2025, 03:45 PM)SpriggsySpriggs Wrote: I feel like this is simple:

Code: (Select All)
Do
    _Limit 30
    x = _KeyHit
    If x Then
        If _KeyDown(100308) Or _KeyDown(100307) Then
            If (x - 32) >= 65 And (x - 32) <= 90 Then
                Print Chr$(x - 32)
            End If
        End If
    End If
Loop
NO BUENO AND A HALF!!!


It's a big thread, but the goal changed from ignoring the Alt key, but by USING an INKEY$ method, which I really should have included using an INKEY$ method in the title, my bad, to converting all possible key reads for _Keyhit into INKEY$.
So let's use your code, add INKEY$ to it, and look at the results. It would be nice if a one-size-fits-all algorithm worked for converting, but honestly I couldn't find one, so the few I did find I used, Steve found one, and the other conditions I just went CASE happy with. See post #11 of this thread: https://qb64phoenix.com/forum/showthread...5#pid38415

So in your example (which is a _Keyhit way to ignore the Alt key) I added INKEY$. NOw the trick this help thread evolved into would require the output on the left to match the output on the right with all keys, not just cap letters, and then the same with Ctrl held down, and the same with just single keystrokes for all keys.

Code: (Select All)
Do
    _Limit 30
    x = _KeyHit
    b$ = InKey$
    If x Then
        If _KeyDown(100308) Or _KeyDown(100307) Then
            If (x - 32) >= 65 And (x - 32) <= 90 Then
                Print Chr$(x - 32), b$ ' Right output needs to match left output here.
            End If
        End If
    End If
Loop

Well I know you're busy, but hey, it's Wednesday.... which means it's hump day! So get to work, newlywed!!! (Sorry, channeling Clippy again) I make a resolution, later tonight, to abstain from that form now on.

Pete Big Grin

P S Kidding aside, sorry I misled you by the title. I'll edit it, now.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Setting mouse to ignore outside of _NewImage PhilOfPerth 11 710 12-18-2025, 07:20 PM
Last Post: Pete
  Stopping repeated mouse-key press PhilOfPerth 8 850 09-02-2025, 11:28 PM
Last Post: Pete
  Is there a _GETALPHA kind of method? Dav 3 765 09-02-2024, 12:09 AM
Last Post: Dav
  Ways to trap function key eoredson 6 1,229 01-20-2024, 06:25 PM
Last Post: SMcNeill
  Processing key input on a do loop NasaCow 9 2,152 04-27-2023, 04:22 PM
Last Post: TerryRitchie

Forum Jump:


Users browsing this thread: 1 Guest(s)