Skip to content

[feat] Allow binding function keys above F12 #2074

@b0o

Description

@b0o
  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows

Problem / Steps to reproduce

Currently fzf only supports binding function keys F1-F12:

fzf/src/tui/tui.go

Lines 75 to 88 in 373c6d8

F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12

This may be a bit of a niche use-case, but I frequently configure my terminal emulator to send keys in the range F13-F36 in place of otherwise undetectable key combos like c-return, c-comma, etc. Most of the time, these high-numbered F-keys don't have any default actions mapped to them in terminal emulators, shells, or TUIs like vim, so they're an ideal set of extra "virtual keys" for this purpose.

Not all terminal emulators necessarily support re-binding key sequences to produce alternate output, but I know a few popular ones definitely do such as alacritty and iTerm2. I use alacritty and accomplish this like so:

key_bindings:
  # Special combos {{{
  - { key: Return,   mods: Control,       chars: "\x1b[24;5~" } # F36
  - { key: Tab,      mods: Alt|Shift,     chars: "\x1b[23;5~" } # F35
  - { key: Comma,    mods: Control,       chars: "\x1b[21;5~" } # F34
  # }}}

I think this would be a good workaround for issues like #1353, #2057, and #918.

Here's a great blog post on F-keys that I often refer to when looking up the escape sequence I need to send to emulate a specific F-key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions