Search code examples
python-3.xkeyboardkeypresspyautogui

Num Lock button press is not working using keyboard module in python3


I am simulating the button press using keyboard module. I have following code:

keyboard.press('num lock')# switching on the num lock key
##do some operation##
keyboard.press('num lock')# num lock key is still On

On second statement num lock key is not pressed down. Please help me to get it resolved.

I have tried with pyautogui,still its not resolved.

pyautogui.press("num lock")

Thanks Simun


Solution

  • The string you need to pass is 'numlock', not 'num lock':

    >>> pyautogui.press("numlock")