QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: johannhowitzer on July 19, 2019, 10:38:12 pm
-
When I use _KEYDOWN with a value such as 100304 for left shift, it works fine, but everything I try for alphanumeric keys doesn't work - such as _KEYDOWN(90) or _KEYDOWN(100090) for the z key. Is this impossible, or is the wiki / help documentation incorrect?
-
Looks OK to me:
-
Your code is working, but mine isn't. It prints everything but the Z and X.
-
Also try _KEYDOWN(122). There’s a different return code for lowercase and uppercase versions of letters.
-
You could use INKEY$ with a PEEK routine...
Pete
-
Let peek and poke rest. If _KEYHIT/_KEYDOWN can’t get it, find the bug in the code, as per McNeil’s suggestion.
-
Huh, the uppercase version works. I wonder why bplus' code worked and mine didn't. Still, that solves my problem.
-
Huh, the uppercase version works. I wonder why bplus' code worked and mine didn't. Still, that solves my problem.
Bplus trapped for both uppercase and lowercase; you need to do the same.
IF _KEYDOWN(90) = true OR _KEYDOWN(122) = true THEN....
Depending on CapsLock state, you’ll generate different key codes.
“Z” is not the same keypress as “z”.
-
Let peek and poke rest. If _KEYHIT/_KEYDOWN can’t get it, find the bug in the code, as per McNeil’s suggestion.
What? Them's fightin' words varmint!
OK, fine, use Windows API, instead...
shift%
= GetAsyncKeyState%
(VK_SHIFT
):
IF shift%
THEN shiftdown%
= -1:
PRINT "shift key down" ctrl%
= GetAsyncKeyState
(VK_CONTROL
):
IF ctrl%
THEN ctrldown%
= -1:
PRINT "ctrl key down"
IF shiftdown%
AND shift%
= 0 THEN PRINT "shift key up": shiftdown%
= 0
- Sam
-
Hi johannhowitzer,
When I hold down the shift key and hold down the z key, your code will print "Z" for me, using vers 1.3 on Windows 10 Laptop.
Remember _KEYDOWN detects keys that are being held down, no recorded buffer.
-
What? Them's fightin' words varmint!
OK, fine, use Windows API, instead...
shift%
= GetAsyncKeyState%
(VK_SHIFT
):
IF shift%
THEN shiftdown%
= -1:
PRINT "shift key down" ctrl%
= GetAsyncKeyState
(VK_CONTROL
):
IF ctrl%
THEN ctrldown%
= -1:
PRINT "ctrl key down"
IF shiftdown%
AND shift%
= 0 THEN PRINT "shift key up": shiftdown%
= 0
- Sam
LOL! Can't kill a fly so call in the SWAT team! :D
-
SWAT the hell are ya talking about now? Oh, ya wants ta know hows ta do it with INP? Well, why didn't ya say so, varmint?
IF lshift%
= 0 THEN PRINT "left shift key down": lshift%
= -1 IF rshift%
= 0 THEN PRINT "right shift key down": rshift%
= -1 IF rshift%
THEN PRINT "right shift key up": rshift%
= 0
-
Hi Pete
fine INP use!
Using on my Toshiba with external USB Keyboard it doesn't detect right Alt key and detects as Ctrl Key the left Alt key...
-
Well you know what they say, Toshiba, Japanese for "I'm sorry!"
Those are the correct scan codes for those keys. For fun, I just plugged in my USB Insignia keyboard to my HP laptop, and the keys work correctly. I have no idea why you are getting different results. Maybe someone who knows more about the hardware can answer that question.
Could you also run the PEEK and Windows API code, and see if you get the same results?
Pete
-
Hi Pete
Yes I have enlarged my experience with your codes...
I get the same results both using INP code both using Windows API code!
And more I tried both using USB Sigma Keyboard both using internal notebook keyboard!
That's all
PS using internal Keyboard I have no limit of _KEYDOWN detected holding more than one key
-
Well you know what they say, Toshiba, Japanese for "I'm sorry!"
コンピューターが「ごめんなさい」ですか? ははは、ほんとうに! 日本語はすごい言葉ね。
-
Dammit Fell, you left the forum door open, and the cat dragged mud in again!
Pete :D
-
TOSHIBA
https://www.youtube.com/watch?v=Jia8IyPKjRc&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=50 (https://www.youtube.com/watch?v=Jia8IyPKjRc&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=50)
https://www.youtube.com/watch?v=MAWN6vDnrpo&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=8 (https://www.youtube.com/watch?v=MAWN6vDnrpo&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=8)
https://www.youtube.com/watch?v=hIoXgMwBzzs&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=25 (https://www.youtube.com/watch?v=hIoXgMwBzzs&list=PL9O-anvIG5KsNFUQSlxTzqwZktXtGyFF-&index=25)
:-)