Reputation: 21
Is there any way to suppress up arrow press physically from keyboard other than do manually the reverse action?
Eg. up arrow press -> manually simulate down press key
Problem: I am trying to autocomplete some words and at up arrow press physically, if I am doing the reverse (simulate down key press) it goes to fully left in the current window. The only solution I see right now is to memorate the lengths of written words and press right key for total length number.
Upvotes: 1
Views: 1546
Reputation: 21
Nvm, I found the answer in another thread:
@Torxed, yes it is related to key-press suppressing and I am using this to create an autocomplete tool.
from pynput import keyboard
def keyboard_listener():
global key
global keyboard_listener
def on_press(key):
print('on press', key)
def on_release(key):
print('on release', key)
if key == keyboard.Key.esc:
return False
def win32_event_filter(msg, data):
if(msg == 257 or msg == 256) and (data.vkCode == 38 or data.vkCode == 40):
listener._suppress = True
else:
listener._suppress = False
return True
return keyboard.Listener(
on_press=on_press,
on_release=on_release,
win32_event_filter=win32_event_filter,
suppress=False
)
listener = keyboard_listener()
if __name__== '__main__':
with listener as ml:
ml.join()
Upvotes: 1