Post

How to Implement OnKeyDown/OnKeyPress Behavior in PowerApps Text Input: Creative Control Workarounds by Paulie M

How to Implement OnKeyDown/OnKeyPress Behavior in PowerApps Text Input: Creative Control Workarounds by Paulie M

Paulie M works around a real gap in Power Apps: the Text Input control has no OnKeyDown or OnKeyPress event, only OnChange, which tells you the text changed but not which key caused it or when exactly it happened.

Quick answer: Power Apps text inputs only expose OnChange - there’s no native per-keystroke event. The workaround: bind a hidden control with its own change event (a Slider or Toggle) to the text input’s value, and use that control’s OnChange/OnCheck to react immediately, comparing the new text to a stored previous value to infer what happened.

The actual gap

TextInput.OnChange fires when the Text property changes - useful, but it only tells you the resulting value, not which key was pressed or when a specific key like Enter was hit. For interactions that genuinely need to react to how the text changed (not just that it did), that’s not enough on its own.

Detecting what changed

Store the previous value in a variable, and compare it to the new one whenever OnChange fires:

// TextInput1.OnChange
If(
    Len(TextInput1.Text) > Len(varPreviousText),
    Set(varLastChar, Right(TextInput1.Text, 1)),
    Set(varLastChar, "")
);
Set(varPreviousText, TextInput1.Text)

This tells you a character was added versus removed, and which character was just typed - enough for live validation, a character counter, or triggering a search once the input reaches a minimum length.

Why a hidden Slider or Toggle helps

For scenarios where you want an event to fire independently of TextInput.OnChange - for example to decouple the “record the keystroke” logic from the “run an expensive filter” logic - bind a hidden control’s value to the text input and hook into its change event instead. A Slider or Toggle both fire their own OnChange/OnCheck and can be positioned off-screen, giving you a second, independently-triggerable event point without touching the text input itself.

Practical uses

  • Live search: once Len(TextInput1.Text) >= 3, filter the data source on every change instead of waiting for focus loss.
  • Real-time validation: check length and character-class rules on each keystroke and reflect the result in the input’s border color.
  • Character counters: update a “X characters remaining” label as the user types.

Limits

This simulates keyboard-style reactivity through the resulting text value - it’s not a true low-level key event, so you still can’t distinguish, say, two different keys that happen to produce the same resulting text. Extra hidden controls also add a little screen complexity to maintain and test across devices.

🛠️ FAQ

Do PowerApps text inputs support OnKeyDown or OnKeyPress events natively?

No. Text input controls only expose OnChange, which fires when the resulting text value changes - not a per-key event.

How can I simulate keyboard-style events in a PowerApps text input?

Bind a hidden control such as a Slider or Toggle to the text input’s value and use that control’s own change event, or compare the new text against a stored previous value inside TextInput.OnChange itself to infer what was typed.

What scenarios can these PowerApps keyboard-event workarounds support?

Real-time search, live validation, character counting, and auto-complete are the practical uses - anything that should react as the user types rather than after they leave the field.

What are the limitations of these keyboard-event workarounds in PowerApps?

They simulate keyboard behavior rather than providing true per-key events, so you can’t distinguish two different keystrokes that produce the same resulting text. Extra hidden controls also add some maintenance and testing overhead across devices.

🔸 #PowerPlatformTip 108: ‘Double-Click Magic in PowerApps’ - the same variable-timing trick, used to detect double clicks Power Apps doesn’t support natively.

🔸 #PowerPlatformTip 78: ‘Efficient Control Reset’ - reset all the hidden helper controls from this pattern with one context variable.


You can see this video here on my blog because I have rated this video with 5 stars in my YouTube video library. This video was automatically posted using PowerAutomate.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.