Onkeydown as option for text_input

Hey all, I’m trying to make an event happen on keydown for a text input, but am not sure if this is an option for text_input. Is this possible?

So I would want something like this after it’s rendered.

<input type="text" onkeydown="function()">

I didn’t see anything similar in the doc

I believe you can add attributes as key value pairs. E.g.:

content_tag :input, id: "foo", class: "bar", onkeydown: someString do
  # inner elements

I haven’t done it with onkeydown, though.

Hello, so this worked for :placeholder. My issue is now that I’m trying to unit test this code it throws an error, even though it’s fine in the actual application. Do you have any idea why I’d get an error like this

** (FunctionClauseError) no function clause matching in Phoenix.HTML.Form.generic_input/4 defp generic_input(type, form, field, opts) when is_list(opts) and (is_atom(field) or is_binary(field))

but my element looks like this

    <%= text_input f, :receiver_address, "1600 Pennsylvania Avenue, Washington DC" %>