May I virtualization a Down arrow key press on Macbook keyboard in macos?

Hello,

On my MacBook Pro 13" Early 2015 the down arrow key is no more working. But I need this key badly while I am coding. So, is there any way to virtualization down arrow key press combining command or alt + UP, LEFT, RIGHT key

Thanks in advance.

MacBook Pro 13″, macOS 11.2

Posted on Nov 21, 2021 10:25 PM

Reply
1 reply

Nov 21, 2021 11:31 PM in response to manobendronath

Finally, I found a solution.

I create a python script using pynput LIB, running on python3.


from pynput import keyboard
from pynput.keyboard import Key, Controller

keyb = Controller()

is_alt_pressed = False
is_shift_pressed = False
is_down_pressed = False
def on_press(key):
    global is_alt_pressed
    global is_shift_pressed
    global is_down_pressed


    if key == Key.shift_l:
        is_shift_pressed = True;
    if key == Key.alt_l:
        is_alt_pressed = True;

    if(is_shift_pressed and is_alt_pressed and (key == Key.up)):
        keyb.press(Key.down)
        is_down_pressed = True

def on_release(key):

    global is_alt_pressed
    global is_shift_pressed
    global is_down_pressed

    if(is_down_pressed):
        is_down_pressed = False
        keyb.release(Key.down)

    if key == Key.shift_l:
        is_shift_pressed = False;
    if key == Key.alt_l:
        is_alt_pressed = False;



# Collect events until released

print("Keyboard macros running...")

with keyboard.Listener(
        on_press=on_press,
        on_release=on_release) as listener:
        listener.join()

And allow all permission to bash shell (Terminal)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

May I virtualization a Down arrow key press on Macbook keyboard in macos?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.