Having keyboard handling appear in view code seems mixing concerns.
Often it does a lot of stuff calculations for a model update, then sends the results as a message.
This can be improved a bit by simply sending the command without doing calculations, but the keyboard code is still pretty unreadable with the json decoding going on. So perhaps we should take some inspiration from a new Elm keyboard package and support writing this like:
We probably do not need to import Skinney/keyboard-events, but could add some code to Options.elm to support this.
Some difficulty is that in the update function we don't have access to the list items, so we may need to pass that along. Also setting preventDefault might depend on calculation.
Having keyboard handling appear in view code seems mixing concerns.
Often it does a lot of stuff calculations for a model update, then sends the results as a message.
This can be improved a bit by simply sending the command without doing calculations, but the keyboard code is still pretty unreadable with the json decoding going on. So perhaps we should take some inspiration from a new Elm keyboard package and support writing this like:
Or more complex:
We probably do not need to import Skinney/keyboard-events, but could add some code to Options.elm to support this.
Some difficulty is that in the update function we don't have access to the list items, so we may need to pass that along. Also setting preventDefault might depend on calculation.