Hello Mendix developers! I am following the Build a Pluggable Widget learning path and everything was fine but the my widget doesn't seem to read the enter key Here is my js code: constructor(props) { super(props); this.onEnterKey = this.onEnterKey.bind(this); } onEnterKey(event) { const { action } = this.props; if (event.which === 13 && action.canExecute) { action.execute(); } } render() { const { attribute } = this.props; return ( <input type="text" value={attribute.value} onKeyDown={this.onEnterKey} /> ) } What is the problem and how can I fix it?
asked
Khaled Alsabbagh
1 answers
1
Hi Khaled,
Keyword event.which is deprecated.
Edit your event handler to replace with the following code:
if (event.key === 'Enter' && action.canExecute)
{
action.execute();
}