Live Chat Icon For mobile
Live Chat Icon

How to read the current value of an input in the OnKeyPress event?

Platform: Blazor| Category: Event handling

To read the current value of an input using @onkeypress event, this event uses the KeyboardEventArgs. You can also get the last pressed key value in args.Key.



<input type="text" @onkeypress="@Keypress" />

@code {
    string KeyPressed = "";
    private void Keypress(KeyboardEventArgs args)
        KeyPressed = "Key Pressed is " + args.Key;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.