# Registering custom editor shortcut with Python scripting.

**URL:** <https://forums.unrealengine.com/t/registering-custom-editor-shortcut-with-python-scripting/2057904>\
**Category:** Programming & Scripting\
**Tags:** Python, unreal-engine, shortcuts, Scripting, question\
**Created:** [October 8, 2024, 12:21am UTC](https://forums.unrealengine.com/t/registering-custom-editor-shortcut-with-python-scripting/2057904 "2024-10-08T00:21:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avelandor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Avelandor](https://forums.unrealengine.com/u/Avelandor)\
**Post date:** [October 8, 2024, 12:21am UTC](https://forums.unrealengine.com/t/registering-custom-editor-shortcut-with-python-scripting/2057904/1 "2024-10-08T00:21:01Z")

</div>

Hello,  
I am trying to implement editor shortcut so that I can invoke my Editor Utility Widget, but I am stuck at the shortcut part.  
This is what I came up with, based on the Python documentation, which should theoretically work, but there is an issue with `unreal.ScriptingCommandInfo`, it doesn’t seem to be exposed to python in the unreal.py (`Error: AttributeError: module 'unreal' has no attribute 'ScriptingCommandInfo'`).

Based on the documentation here, I would expect to be able to use this class, am I misunderstanding something, or is this issue on the API side? I am on 5.4.  
[https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/ScriptingCommandInfo?application\_version=5.4#unreal.ScriptingCommandInfo](https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/ScriptingCommandInfo?application_version=5.4#unreal.ScriptingCommandInfo)

```auto
import unreal

def register_shortcut():
    editor_commands = unreal.get_editor_subsystem(unreal.LevelSequenceEditorSubsystem)
    # Function to be executed when shortcut is pressed
    def on_shortcut_pressed():
        unreal.log("Ctrl+J was pressed!")

    input_chord = unreal.InputChord()
    input_chord.ctrl = True # Enable Ctrl modifier
    # input_chord.shift = False
    # input_chord.alt = False
    chord_key = unreal.Key()
    chord_key.set_editor_property("key_name", "J") # Get the key object
    print(chord_key.get_editor_property("key_name")) # Get the key object
    input_chord.key = chord_key # The main key to trigger the shortcut

    scripting_command_info = unreal.ScriptingCommandInfo()
    scripting_command_info.name = "PythonCommand.CustomShortcut"
    scripting_command_info.label = "Custom Ctrl+J Shortcut"
    scripting_command_info.description = "Executes custom functionality when Ctrl+J is pressed"
    scripting_command_info.input_chord = input_chord

    # Register the command
    editor_commands.register_command(
        command_info=scripting_command_info,
        execute_command=on_shortcut_pressed,
        default_desc="Custom Ctrl+J Shortcut",
        help_text="Executes custom functionality when Ctrl+J is pressed",
    )

# Call the function to register the shortcut
register_shortcut()

```

If this is incorrect approach for registering shortcuts, I would appreciate hints for the alternative.
