Skip to content

Instantly share code, notes, and snippets.

@neslinesli93
Created January 2, 2020 20:55
Show Gist options
  • Save neslinesli93/4ff814c33b146794472899c3e9cc2ed1 to your computer and use it in GitHub Desktop.
Save neslinesli93/4ff814c33b146794472899c3e9cc2ed1 to your computer and use it in GitHub Desktop.
Add basic event handlers to game module
@spec handle_event(String.t(), map(), Socket.t()) :: {:noreply, Socket.t()} | {:stop, Socket.t()}
def handle_event("keydown", payload, socket) do
IO.puts("Received keydown event")
IO.inspect(payload, label: "Payload for keydown")
{:noreply, socket}
end
def handle_event("keyup", payload, socket) do
IO.puts("Received keyup event")
IO.inspect(payload, label: "Payload for keyup")
{:noreply, socket}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment