Skip to content
Sign upLog in
← Back to Community
how do i get keyboard included in a repl
Profile icon
jnrchewie

without using from keyboard import

Answered by Wumi4 [earned 5 cycles]
View Answer
Voters
Profile icon
jnrchewie
Comments
hotnewtop
Profile icon
Wumi4

Just import them as usual!

# The example from the official documentation import keyboard keyboard.press_and_release('shift+s, space') keyboard.write('The quick brown fox jumps over the lazy dog.') keyboard.add_hotkey('ctrl+shift+a', print, args=('triggered', 'hotkey')) # Press PAGE UP then PAGE DOWN to type "foobar". keyboard.add_hotkey('page up, page down', lambda: keyboard.write('foobar')) # Blocks until you press ESC. keyboard.wait('esc') # Record events until 'ESC' is pressed. recorded = keyboard.record(until='esc') # Then replay back at three times the speed. keyboard.play(recorded, speed_factor=3) # Type @@ then press space to replace with abbreviation. keyboard.add_abbreviation('@@', '[email protected]') # Block forever, like `while True`. keyboard.wait()
Profile icon
MarcBauchet

@Wumi4
that doesn't work, keyboard requires root on liux, so unsuprisingly i get: ImportError: You must be root to use this library on linux.

Profile icon
MarcBauchet

with that one, no need for root access in linux:
https://sshkeyboard.readthedocs.io/en/latest/
i had to install it in Replit though

Profile icon
PattanAhmed

Can you please clarify your question.

Profile icon
[deleted]

Which programming language are you using?

Profile icon
jnrchewie