For those who want to achieve this on Linux,
I made a c++ program to capture mouse click and have
Enter key pressed just after.
int main(int argc, char **argv)
struct input_event event;
int fd, bytes;
unsigned char data;
bool down = false;
const char *pDevice = "/dev/input/by-id/usb-Logitech_USB_Receiver-if01-event-mouse";
fd = open(pDevice, O_RDONLY | O_NONBLOCK);
if (fd == -1)
printf("ERROR Opening %s\n", pDevice);
memset((void *)&event, 0, sizeof(event));
bytes = read(fd, (void *)&event, sizeof(event));
if (event.type == 1 && event.code == 272 && event.value == 1)
down = true;
if (event.type == 1 && event.code == 272 && event.value == 0)
down = false;
system("xdotool key Return");
In the above program I tried to read the mouse events and data directly from the device in "/dev/input/by-id", my device events file name is "usb-Logitech_USB_Receiver-if01-event-mouse".
Once you have the events in a variable (i.e event), my mouse left button code is 272, not sure it is the universal code number for mouse left button, event.type = 1 ( not sure about this even ), event.value = 1 is mouse button down/pressed event whereas event.value = 0 is mouse up/released event.
Once mouse is pressed we have to hit
Enter key on keyboard, for that I used
xdotool, make sure you installed
xdotool key Return triggers the Enter key pressed event on keyboard.
compile it to produce an executable named
then you can run it using
& is to run the command in background.
Thats it, now whenever your mouse left key is pressed, the
Enter key on your keyboard is pressed until you release the button click.
Note: This program uses 100% cpu coz of the infinite while loop, but its normal.
I tested this on cs1.6 when I fired from pistol using mouse left key down, whole round fired automatically coz of
Enter key pressed till I held the mouse key up.
Make sure you put
Enter key to Fire in keyboard shotcuts in settings of cs1.6, I have
Enter key as primary and
- key as alternate to Fire in keyboard shortcuts.