keystroke detection

Discussions related to mouse, keyboard and Graphical User Interface
Post Reply
Posts: 18
Joined: Tue 17 Apr 2018, 21:03

keystroke detection

Post by Ric » Mon 29 Jul 2019, 21:38

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


User avatar
Posts: 37
Joined: Sat 09 Jun 2018, 09:47

Re: keystroke detection

Post by hellomike » Tue 30 Jul 2019, 19:31

Hi Ric,

Not sure what you tried but when I run the following:

Code: Select all

        WAIT 0
        MOUSE X%,Y%,B%
        IF B% IF INKEY(-1) N%+=1 : PRINT "Mouse clicked AND <shift> pressed... ";N%
      UNTIL 0
It will print text only when both a <shift> key is pressed and a mouse button is clicked.



Posts: 146
Joined: Mon 02 Apr 2018, 18:04

Re: keystroke detection

Post by DDRM » Mon 05 Aug 2019, 08:31

This seems to work fine:

Code: Select all

        WAIT 1
        MOUSE x%,y%,z%
        PRINT x%,y%
        IF INKEY(-67) THEN PRINT "X down"
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,


Post Reply