I’m working with a Dash Mantine TextInput component. I want to trigger a callback only when the “Enter” key is pressed. I’ve gotten a working prototype using a Dash Extensions EventListener. However, it seems that an EventListener can only trigger a “keydown” event for the keys listed in the documentation – “key”, “ctrlKey”, etc. I really don’t like how the server code needs to check for the “Enter” key on every key press and ignore everything but the “Enter” key:
if "key" in event:
if event["key"] != "Enter":
return no_update
At this point I’m leaning towards creating my own clientside_callback to simulate a button click when the “Enter” key is pressed. Before I do, can someone tell if I’m doing something wrong with EventListener? Can I specify a key in the “events” prop like the following:
de.EventListener(
dmc.TextInput(
id="message",
),
events=[{"event": "keydown", "props": ["Enter"]}],
id="enter-key-listener",
),
Thanks in advance for any response!