Press a key on keyboard using Python script

Is there any way to press a key on the keyboard using Python Script?

If Yes, please suggest.

looks like there may be a few ways by googling, never tried it myself though:

https://datatofish.com/control-keyboard-python/

1 Like

You can emulate a keyboard press using async def emulate_keyboard_press( key: KeyboardInput, modifier: carb.input.KeyboardInput = 0, human_delay_speed: int = 2 )

import asyncio
from omni.kit.ui_test import emulate_keyboard_press
from carb.input import KeyboardInput

async def press_enter():
    await emulate_keyboard_press(KeyboardInput.ENTER)

run_loop = asyncio.get_event_loop()
run_loop.create_task(press_enter())

1 Like

this is good to know! thanks, Jen!