Skip to content

Cannot override Text KeyMap #73

Closed
Closed
@guigui64

Description

Describe the bug
WithKeyMap does not seem to have any effect on the Text field.

To Reproduce
Steps to reproduce the behavior:

textField := huh.NewText().
	Title("...").
	Value(&message).
	WithKeyMap(&huh.KeyMap{
		Text: huh.TextKeyMap{
			Next:    key.NewBinding(key.WithKeys("ctrl+enter"), key.WithHelp("ctrl+enter", "next")),
			Prev:    key.NewBinding(key.WithKeys("shift+tab"), key.WithHelp("shift+tab", "back")),
			NewLine: key.NewBinding(key.WithKeys("enter", "ctrl+j"), key.WithHelp("enter / ctrl+j", "new line")),
			Editor:  key.NewBinding(key.WithKeys("ctrl+e"), key.WithHelp("ctrl+e", "open editor")),
		},
	})

form := huh.NewForm(
	huh.NewGroup(
		textField,
	),
)

Help text at the end of the field does not reflect the new KeyMap and the default keymap still applies.

Expected behavior
Next and NewLine should have been overriden.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions