Repository: wagtail/wagtail
File: wagtail/admin/wagtail_hooks.py (Python)

Code before:
def register_whats_new_in_wagtail_version_menu_item():
    version = "6.1"
    return DismissibleMenuItem(
        _("What's new in Wagtail %(version)s") % {"version": version},
        wagtail_feature_release_whats_new_link(),
        icon_name="help",
        order=1000,
        attrs={"target": "_blank", "rel": "noreferrer"},
        name=f"whats-new-in-wagtail-{version}",
    )


@hooks.register("register_help_menu_item")
def register_editors_guide_menu_item():
    return DismissibleMenuItem(
        _("Editor Guide"),
        wagtail_feature_release_editor_guide_link(),
        icon_name="help",
        order=1100,
        attrs={"target": "_blank", "rel": "noreferrer"},
        name="editor-guide",
    )


@hooks.register("register_help_menu_item")
def register_keyboard_shortcuts_menu_item():
    return MenuItem(
        _("Shortcuts"),
        icon_name="regex",
        order=1200,
        attrs={
            "role": "button",
            "data-a11y-dialog-show": "keyboard-shortcuts-dialog",
            "data-action": "w-action#noop:prevent:stop",
            "data-controller": "w-action",
        },
        name="keyboard-shortcuts-trigger",
        url="#",
    )


@hooks.register("register_admin_menu_item")
def register_help_menu():
    return DismissibleSubmenuMenuItem(
        _("Help"),
        help_menu,
        name="help",
        icon_name="help",
        order=11000,
    )


Review comment (suggestion):
Let's add a simple docstring here, helps for future context. I can add this when merging.

```suggestion
def register_keyboard_shortcuts_menu_item():
    """
    Triggers the keyboard shortcuts dialog to open when clicked
    while preventing the default link click action.
    """

```

Code after:
def register_whats_new_in_wagtail_version_menu_item():
    version = "6.1"
    return DismissibleMenuItem(
        _("What's new in Wagtail %(version)s") % {"version": version},
        wagtail_feature_release_whats_new_link(),
        icon_name="help",
        order=1000,
        attrs={"target": "_blank", "rel": "noreferrer"},
        name=f"whats-new-in-wagtail-{version}",
    )


@hooks.register("register_help_menu_item")
def register_editors_guide_menu_item():
    return DismissibleMenuItem(
        _("Editor Guide"),
        wagtail_feature_release_editor_guide_link(),
        icon_name="help",
        order=1100,
        attrs={"target": "_blank", "rel": "noreferrer"},
        name="editor-guide",
    )


@hooks.register("register_help_menu_item")
def register_keyboard_shortcuts_menu_item():
    """
    Triggers the keyboard shortcuts dialog to open when clicked
    while preventing the default link click action.
    """

    return MenuItem(
        _("Shortcuts"),
        icon_name="regex",
        order=1200,
        attrs={
            "role": "button",  # Ensure screen readers announce this as a button
            "data-a11y-dialog-show": "keyboard-shortcuts-dialog",
            "data-action": "w-action#noop:prevent:stop",
            "data-controller": "w-action",
        },
        name="keyboard-shortcuts-trigger",
        url="#",
    )


@hooks.register("register_admin_menu_item")
def register_help_menu():
    return DismissibleSubmenuMenuItem(
        _("Help"),
        help_menu,