If i wish to detect a key stroke at the same time as the mouse movement, if i choose a key such as "shift", this is possible by using INKEY(minus argumant). But if i try this with a lettered key, when i hold down say "X" then the MOUSE x,y,b seems to do nothing and thus the two can not be detected together. Am i doing something wrong or is in not possible to do what i want.
I would like to hold down various keys and then with the mouse movement make different things happen.
Here's hoping
Ric
keystroke detection
-
- Posts: 200
- Joined: Tue 17 Apr 2018, 21:03
keystroke detection
Kind Regards Ric.
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
- hellomike
- Posts: 184
- Joined: Sat 09 Jun 2018, 09:47
- Location: Amsterdam
Re: keystroke detection
Hi Ric,
Not sure what you tried but when I run the following:It will print text only when both a <shift> key is pressed and a mouse button is clicked.
Regards,
Mike
Not sure what you tried but when I run the following:
Code: Select all
REPEAT
WAIT 0
MOUSE X%,Y%,B%
IF B% IF INKEY(-1) N%+=1 : PRINT "Mouse clicked AND <shift> pressed... ";N%
UNTIL 0
Regards,
Mike
Re: keystroke detection
This seems to work fine:
The x,y coordinates of the mouse seem to continue to change even while the X is pressed - so presumably I'm misunderstanding your problem. Can you post a brief example of your code, and explain what it doesn't do that you want it to?
Best wishes,
D
Code: Select all
REPEAT
WAIT 1
MOUSE x%,y%,z%
PRINT x%,y%
IF INKEY(-67) THEN PRINT "X down"
UNTIL FALSE
Best wishes,
D
-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: keystroke detection
It should be noted that ON MOUSE provides a way of telling whether SHIFT or CTRL are held down (see the help files for details). However for other keys you will have to use a negative inkey to test for the specific key. This can be a nuisance if you have half a dozen keys that need to be checked, but I don't know of any other method.