Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.8.1 (compiled with Erlang/OTP 20)
* phoenix 1.4.2 (Hex package) (mix)
locked at 1.4.2 (phoenix) 3a1250f2
ok
* phoenix_live_reload 1.2.0 (Hex package) (mix)
locked at 1.2.0 (phoenix_live_reload) 3bb31a9f
ok
* phoenix_live_view 0.1.0 (https://github.com/phoenixframework/phoenix_live_view.git) (mix)
locked at d77f787
ok
v8.9.1
6.9.0
Distributor ID: Ubuntu
Description: Ubuntu 14.04.6 LTS
Release: 14.04
Codename: trusty
When pressing multiple keys in a row, only the first fires an event. This is due to the line below:
It should register every keypress, even if a duplicate.
+1 for this. The current behavior surprised me, and I spent some time thinking something was wrong with the socket connection since some keys were ignored until I saw this issue.
I was using phx-keyup to make a stand-alone <input type="text> field outside a form. When I first did this, it seemed very strange that only some keypresses were ignored in live view.
A solution to this was to use a complete form, e.g.
<form phx-change="new_filter">
<input type="text" name="filter" value="<%= @filter %>" />
</form>
This will work, and it registers every keypress, also duplicates.
Having worked with javascript for a long time, I am used to working with target.addEventListener('keyup', eventHandlerFn); where the eventHandlerFn captures all keyup events unfiltered. The same can be done in a lot of frontend frameworks, e.g. Angular, React and Vue. For example, Vue would bind to the keyup event using v-keyup.
What is the reason for filtering out duplicate keypresses? In my opinion the keypresses should be always be sent.
This is a bug intended to throttle keypress repeats that looks like it affects all key events. I will fix. Thanks!
closed via #99
Most helpful comment
This is a bug intended to throttle keypress repeats that looks like it affects all key events. I will fix. Thanks!