1package keymap23import "charm.land/bubbles/v2/key"45// KeyMap is a map of key bindings for the UI.6type KeyMap struct {7 Quit key.Binding8 Up key.Binding9 Down key.Binding10 UpDown key.Binding11 LeftRight key.Binding12 Arrows key.Binding13 GotoTop key.Binding14 GotoBottom key.Binding15 Select key.Binding16 Section key.Binding17 Back key.Binding18 PrevPage key.Binding19 NextPage key.Binding20 Help key.Binding2122 SelectItem key.Binding23 BackItem key.Binding2425 Copy key.Binding26}2728// DefaultKeyMap returns the default key map.29func DefaultKeyMap() *KeyMap {30 km := new(KeyMap)3132 km.Quit = key.NewBinding(33 key.WithKeys(34 "q",35 "ctrl+c",36 ),37 key.WithHelp(38 "q",39 "quit",40 ),41 )4243 km.Up = key.NewBinding(44 key.WithKeys(45 "up",46 "k",47 ),48 key.WithHelp(49 "↑",50 "up",51 ),52 )5354 km.Down = key.NewBinding(55 key.WithKeys(56 "down",57 "j",58 ),59 key.WithHelp(60 "↓",61 "down",62 ),63 )6465 km.UpDown = key.NewBinding(66 key.WithKeys(67 "up",68 "down",69 "k",70 "j",71 ),72 key.WithHelp(73 "↑↓",74 "navigate",75 ),76 )7778 km.LeftRight = key.NewBinding(79 key.WithKeys(80 "left",81 "h",82 "right",83 "l",84 ),85 key.WithHelp(86 "←→",87 "navigate",88 ),89 )9091 km.Arrows = key.NewBinding(92 key.WithKeys(93 "up",94 "right",95 "down",96 "left",97 "k",98 "j",99 "h",100 "l",101 ),102 key.WithHelp(103 "↑←↓→",104 "navigate",105 ),106 )107108 km.GotoTop = key.NewBinding(109 key.WithKeys(110 "home",111 "g",112 ),113 key.WithHelp(114 "g/home",115 "goto top",116 ),117 )118119 km.GotoBottom = key.NewBinding(120 key.WithKeys(121 "end",122 "G",123 ),124 key.WithHelp(125 "G/end",126 "goto bottom",127 ),128 )129130 km.Select = key.NewBinding(131 key.WithKeys(132 "enter",133 ),134 key.WithHelp(135 "enter",136 "select",137 ),138 )139140 km.Section = key.NewBinding(141 key.WithKeys(142 "tab",143 "shift+tab",144 ),145 key.WithHelp(146 "tab",147 "section",148 ),149 )150151 km.Back = key.NewBinding(152 key.WithKeys(153 "esc",154 ),155 key.WithHelp(156 "esc",157 "back",158 ),159 )160161 km.PrevPage = key.NewBinding(162 key.WithKeys(163 "pgup",164 "b",165 "u",166 ),167 key.WithHelp(168 "pgup",169 "prev page",170 ),171 )172173 km.NextPage = key.NewBinding(174 key.WithKeys(175 "pgdown",176 "f",177 "d",178 ),179 key.WithHelp(180 "pgdn",181 "next page",182 ),183 )184185 km.Help = key.NewBinding(186 key.WithKeys(187 "?",188 ),189 key.WithHelp(190 "?",191 "toggle help",192 ),193 )194195 km.SelectItem = key.NewBinding(196 key.WithKeys(197 "l",198 "right",199 ),200 key.WithHelp(201 "→/l",202 "select",203 ),204 )205206 km.BackItem = key.NewBinding(207 key.WithKeys(208 "h",209 "left",210 "backspace",211 ),212 key.WithHelp(213 "←/h",214 "back",215 ),216 )217218 km.Copy = key.NewBinding(219 key.WithKeys(220 "c",221 "ctrl+c",222 ),223 key.WithHelp(224 "c",225 "copy text",226 ),227 )228229 return km230}