Skip to content

Commit

Permalink
docs(README): account for keydown changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lessp authored and leostera committed Apr 4, 2024
1 parent 04942ef commit b084ec7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 121,24 @@ possibility of using custom events.
let update event model =
match event with
(* if we press `q` or the escape key, we exit *)
| Event.KeyDown (Key "q" | Escape) -> (model, Command.Quit)
| Event.KeyDown ((Key "q" | Escape), _modifier) -> (model, Command.Quit)
(* if we press up or `k`, we move up in the list *)
| Event.KeyDown (Up | Key "k") ->
| Event.KeyDown ((Up | Key "k"), _modifier) ->
let cursor =
if model.cursor = 0 then List.length model.choices - 1
else model.cursor - 1
in
({ model with cursor }, Command.Noop)
(* if we press down or `j`, we move down in the list *)
| Event.KeyDown (Down | Key "j") ->
| Event.KeyDown ((Down | Key "j"), _modifier) ->
let cursor =
if model.cursor = List.length model.choices - 1 then 0
else model.cursor 1
in
({ model with cursor }, Command.Noop)
(* when we press enter or space we toggle the item in the list
that the cursor points to *)
| Event.KeyDown (Enter | Space) ->
| Event.KeyDown ((Enter | Space), _modifier) ->
let toggle status =
match status with `selected -> `unselected | `unselected -> `selected
in
Expand Down

0 comments on commit b084ec7

Please sign in to comment.