Private/UI/Test-PSMBArrowKeySupport.ps1

function Test-PSMBArrowKeySupport {
    <#
    .SYNOPSIS
        Checks if the current host supports arrow-key interactive menus.
    .DESCRIPTION
        Returns $true on PowerShell 7+ with an interactive console host that
        supports RawUI key reading. Returns $false on unsupported hosts such
        as ISE, CI runners, Pester test hosts, and non-interactive sessions.
    #>

    [CmdletBinding()]
    [OutputType([bool])]
    param()

    if ($PSVersionTable.PSVersion.Major -lt 7) {
        return $false
    }

    if (-not [Environment]::UserInteractive) {
        return $false
    }

    if ($Host.Name -ne 'ConsoleHost') {
        return $false
    }

    try {
        $null = $Host.UI.RawUI.KeyAvailable
        return $true
    }
    catch {
        return $false
    }
}