question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add handler for OnKeyUp( enter ) on form/page

See original GitHub issue

Hi Chris,

Thanks for the control - it’s great! 😃

I have an input where I’m tying in an event to the Enter key, so that somebody can type in a string, and when they hit enter it’ll trigger an action to update the underlying object. So I have:

<input @bind-value=“NewTag” @bind-value:event=“oninput” @onkeyup=“ProcessEnterKey” >

@code:

private void ProcessEnterKey( KeyboardEventArgs eventArgs)
    {
        if (eventArgs.Key == "Enter" )        // fire on enter 
            SaveTheData();
    }

Unfortunately, if I try and use this with the BlazoredTypeAhead like this:

<BlazoredTypeahead SearchMethod="SearchTags" @bind-Value="NewTag" @onkeyup="ProcessEnteEnterr">

it breaks the Typeahead control - I think because it replaces your control’s internal onkeyup Handler. I’m relatively new to Blazor - is there a way to have both handlers in place, or is there a trivial way to extend the Typeahead keyup handler? I was going to derive a custom class using the BlazoredTypeAhead as the base, and then override the OnKeyUp method to extend it, but to do this, your KeyUp handler would need to be virtual. Is there a better, or more idiomatic way to do this in Blazor?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Webreapercommented, Oct 28, 2019

Haha - sure. I was likely to get to this in about 6-8 weeks, if I’m lucky, so no risk of doing anything which will interfere with the work you’re doing on that issue. 😃

1reaction
chrissaintycommented, Oct 28, 2019

I’m going to close this issue in favor of the existing one, if that’s ok with you @Webreaper? If you feel anything is not being covered please re-open.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use the Enter Key Event Handler on a React- ...
In this guide, you'll learn about keyboard events and how to submit a form using the enter key event handler for the input...
Read more >
Submit a form with Enter key with JavaScript/jQuery
keyup (handler) method and use that handler to submit the form. To determine the specific key that was pressed, you can use the...
Read more >
Submitting a form on 'Enter' with jQuery? - javascript
At first I added an eventhandler to the submit button which produced an error for me. I found out today the keypress event...
Read more >
How To Trigger Button Click on Enter
Trigger a button click on keyboard "enter" with JavaScript. Trigger a Button Click on Enter. Press the "Enter" key inside the input field...
Read more >
The Enter Key should Submit Forms, Stop Suppressing it
When enter is clicked in the number input, the keypress event handler determines which submit button is appropriate and clicks it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found