# Trigger InputRule on enter?

**URL:** <https://discuss.prosemirror.net/t/trigger-inputrule-on-enter/1118>\
**Category:** Uncategorized\
**Created:** [December 23, 2017, 10:33pm UTC](https://discuss.prosemirror.net/t/trigger-inputrule-on-enter/1118 "2017-12-23T22:33:19Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![davidb](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/davidb/32/4237_2.png) [@davidb](https://discuss.prosemirror.net/u/davidb)\
**Post date:** [September 11, 2024, 12:47pm UTC](https://discuss.prosemirror.net/t/trigger-inputrule-on-enter/1118/7 "2024-09-11T12:47:19Z")

</div>

I was able to condense @bhl 's solution so that it can be added to what `inputRules` returns, that way you don’t have to duplicate the library code:

```auto
  const rplugin = inputRules({ rules: [/* ... your rules */] });

  const hkd = (view, event) => {
    if (event.key !== 'Enter') return false;
    const { $cursor } = view.state.selection;
    if ($cursor) return rplugin.props.handleTextInput(view, $cursor.pos, $cursor.pos, '\n');
    return false;
  };
  rplugin.props.handleKeyDown = hkd; // Add the handleKeyDown function

```

And yes, I also noticed this:

> [@](#):
>
> Add the inputRule plugin in front of the keymap plugin

Thanks everyone for the help! It works perfectly!

---

_[View the full topic](https://discuss.prosemirror.net/t/trigger-inputrule-on-enter/1118)._
