Skip to content

Learn keys should support Ctrl/Meta/Shift modifiers and save modifier-aware terminal entries #5027

@ilia-maslakov

Description

@ilia-maslakov

Is there an existing request for this?

  • I have searched the existing issues

Is your feature request related to a problem?

Yes. Learn keys can currently teach base keys, but it does not provide an explicit way to teach/save modified
variants as separate terminal mappings (for example shift-up, ctrl-f9, meta-right).
As a result, users often have to manually edit ~/.config/mc/ini under [terminal:TERM], and it is hard to reliably
persist modifier-specific escape sequences.

Describe the solution you'd like

Add explicit modifier-aware key learning to the Learn keys dialog.

Expected behavior:

  • Provide three modifier toggles: [ ] Ctrl, [ ] Meta (Alt), [ ] Shift.
  • When learning a key, selected modifiers are applied to that key definition.
  • Save learned sequences in [terminal:TERM] with modifier-prefixed key names, for example:
    • shift-up=...
    • ctrl-f9=...
    • meta-right=...
    • combined forms for multiple selected modifiers.
  • Keep modifier controls in a separate, non-overlapping row in the dialog so layout remains readable.
  • Preserve existing behavior when no modifiers are selected (base key names remain unchanged).

Describe alternatives you've considered

• 1. Manual editing of ~/.config/mc/ini ([terminal:TERM]) after using Learn keys.
This works, but it is error-prone and not user-friendly for common modifier mappings.
2. Using only keymap-level remapping (mc.keymap) without terminal mapping changes.
This does not help when the terminal sequence itself is unknown or not learned correctly in the terminal
section.
3. Relying on terminal/terminfo fixes only.
Helpful in some environments, but it does not solve the usability gap in MC’s own key-learning workflow for
modifier variants.

Additional context

In many terminals, modified arrows/function keys emit different escape sequences (for example CSI 1;2A, CSI 1;5C,
etc.).
cat -v may show distinct sequences, but Learn keys currently stores only base key entries, so users still need
manual ini edits for modifier variants.

A practical target is to allow learning and persisting entries such as:

[terminal:xterm]
up=\e[A
down=\e[B
left=\e[D
right=\e[C

shift-up=\e[1;2A
shift-down=\e[1;2B
shift-right=\e[1;2C
shift-left=\e[1;2D
ctrl-f9=...
meta-right=...

This would make terminal-specific modifier setup reproducible and avoid post-editing config files.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions