I am using the Curtsies library to detect key presses but it only works when I’m tabbed into the terminal when I want to to work even when I’m not in the terminal. Note: I am also using the pyautogui library to move my mouse and I use a Debian GNU/Linux distro. My code:
`from curtsies import Input
import pyautogui
binds = [(‘b’,100,100)]
while True:
with Input() as input_generator:
for i in input_generator:
for i2 in binds:
if i == i2[0]:
pyautogui.moveRel(i2[1],i2[2])`
Is there a way to make it work with this library or a possible alternative?
I tried to use my script while not in the terminal but it doesn’t register my key presses.
This worked for me (even if you’re not in the terminal).
import keyboard
import pyautogui
binds = [('b', 100, 100)]
while True:
if keyboard.is_pressed('esc'):
break
for key, x_offset, y_offset in binds:
if keyboard.is_pressed(key):
pyautogui.moveRel(x_offset, y_offset)
Nabih Samy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1