Skip to content

Ghostty issue w shifted Fn keys #5056

@edrozenberg

Description

@edrozenberg

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

GNU Midnight Commander 4.8.33
Built with GLib 2.82.4
Built with S-Lang 2.3.3 with terminfo database
Built with libssh2 1.11.1
With builtin editor
With subshell support as default
With support for background operations
With mouse support on xterm
With internationalization support
With multiple codepages support
Virtual File Systems:
 cpiofs, tarfs, sfs, extfs, ftpfs, sftpfs, shell
Data types:
 char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64; uintmax_t: 64;

Operating system

Darwin viper 24.6.0 Darwin Kernel Version 24.6.0: Mon Jan 19 22:01:58 PST 2026; root:xnu-11417.140.69.708.3~1/RELEASE_ARM64_T6041 arm64

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

  • Run Ghostty terrminal app
  • Doublecheck that TERM is set to TERM=xterm-ghostty (default value)
  • Run mc
  • Press Shift + F4, this will have the effect of Shift + F6

Expected behavior

For ex. Shift + F4 has the effect of Shift + F4

Actual behavior

For ex. Shift + F4 has the effect of Shift + F6

Additional context

When using the Ghostty terminal app (Mac/Linux), shifted Fn combos (for ex. Shift + F6) are interpreted as being a +2 Fn key. So in order to make mc perform a Shift + F6 (rename) the user needs to press Shift + F4.

This appears due to mc hardcoding various behaviors and not currently hardcoding the proper handling for Ghostty.

Issue reported to Ghostty here:
ghostty-org/ghostty#4681
ghostty-org/ghostty#3777

And responded by Ghostty as likely an mc issue with additional suggestions of related items:

mc/lib/tty/tty.c

Lines 113 to 125 in a37ae1c

static const char *xterm_compatible_terminals[] = {
"alacritty", //
"contour", //
"dtterm", //
"Eterm", //
"foot", //
"konsole", //
"rxvt", //
"screen", //
"tmux", //
"xterm", //
NULL,
};

https://github.com/MidnightCommander/mc/blob/master/lib/tty/key.c#L318

#4762

I suspect the easiest short-term solution would be for mc to hardcode detection of the Ghostty terminal as being xterm-compatible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ttyInteraction with the terminal, screen librariesprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions