'Run a keyboard macro in Google Chrome

So, I have this code which basically writes a text after I press the shortcut " Shift + A". This went fine, however when I'm trying to press the shortcut in Google Chrome, to input the text, but nothing happens.

I just want that when I press Shift + A inside Google Chrome, the text is inserted where I selected.

Could someone please help me? Thanks!

Please see the code below:

from pynput import keyboard

# The key combination to check
COMBINATIONS = [
    {keyboard.Key.shift, keyboard.KeyCode(char='a')},
    {keyboard.Key.shift, keyboard.KeyCode(char='A')}
]

# The currently active modifiers
current = set()


def execute():
    print("Do Something")


def on_press(key):
    if any([key in COMBO for COMBO in COMBINATIONS]):
        current.add(key)
        if any(all(k in current for k in COMBO) for COMBO in COMBINATIONS):
            execute()


def on_release(key):
    if any([key in COMBO for COMBO in COMBINATIONS]):
        current.remove(key)


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


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source