@@ -7,8 +7,6 @@ import (
type KeyMap struct {
Down,
Up,
- NDown,
- NUp,
DownOneItem,
UpOneItem,
HalfPageDown,
@@ -20,34 +18,36 @@ type KeyMap struct {
func DefaultKeyMap() KeyMap {
return KeyMap{
Down: key.NewBinding(
- key.WithKeys("down", "ctrl+j", "ctrl+n"),
+ key.WithKeys("down", "ctrl+j", "ctrl+n", "j"),
+ key.WithHelp("↓", "down"),
),
Up: key.NewBinding(
- key.WithKeys("up", "ctrl+k", "ctrl+p"),
- ),
- NDown: key.NewBinding(
- key.WithKeys("j"),
- ),
- NUp: key.NewBinding(
- key.WithKeys("k"),
+ key.WithKeys("up", "ctrl+k", "ctrl+p", "k"),
+ key.WithHelp("↑", "up"),
),
UpOneItem: key.NewBinding(
key.WithKeys("shift+up", "K"),
+ key.WithHelp("shift+↑", "up one item"),
),
DownOneItem: key.NewBinding(
key.WithKeys("shift+down", "J"),
+ key.WithHelp("shift+↓", "down one item"),
),
HalfPageDown: key.NewBinding(
key.WithKeys("d"),
+ key.WithHelp("d", "half page down"),
),
HalfPageUp: key.NewBinding(
key.WithKeys("u"),
+ key.WithHelp("u", "half page up"),
),
Home: key.NewBinding(
key.WithKeys("g", "home"),
+ key.WithHelp("g", "home"),
),
End: key.NewBinding(
key.WithKeys("G", "end"),
+ key.WithHelp("G", "end"),
),
}
}
@@ -57,8 +57,6 @@ func (k KeyMap) KeyBindings() []key.Binding {
return []key.Binding{
k.Down,
k.Up,
- k.NDown,
- k.NUp,
k.DownOneItem,
k.UpOneItem,
k.HalfPageDown,
@@ -254,10 +254,6 @@ func New(opts ...listOptions) ListModel {
ti.Focus()
ti.SetStyles(t.S().TextInput)
m.input = ti
-
- // disable j,k movements
- m.keyMap.NDown.SetEnabled(false)
- m.keyMap.NUp.SetEnabled(false)
}
return m
}
@@ -319,9 +315,9 @@ func (m *model) View() tea.View {
// Supports scrolling, item selection, and navigation to top/bottom.
func (m *model) handleKeyPress(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
switch {
- case key.Matches(msg, m.keyMap.Down) || key.Matches(msg, m.keyMap.NDown):
+ case key.Matches(msg, m.keyMap.Down):
m.scrollDown(1)
- case key.Matches(msg, m.keyMap.Up) || key.Matches(msg, m.keyMap.NUp):
+ case key.Matches(msg, m.keyMap.Up):
m.scrollUp(1)
case key.Matches(msg, m.keyMap.DownOneItem):
return m, m.selectNextItem()