I just saw that liveview 0.8.0 was released so I decided to migrate my pet project that I built using 0.4.0 to the latest version. The project compiles but for some reason my keyboard events stopped working.
This PR has the changes I’ve made so far to upgrade the project.
My guess is that the API changed somehow, but I can’t find how exactly.
This is my template:
<div phx-keydown="keydown" phx-target="window" class="game-field">
...
</div>
...
And this my *_live file:
def handle_event("keydown", %{"key" => "Escape"}, socket) do
new_socket =
case socket.assigns do
%{state: :paused} ->
continue_game(socket)
%{state: :playing} ->
pause_game(socket)
_ ->
socket
end
{:noreply, new_socket}
end