Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6190459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:35:37+00:00 2026-05-24T02:35:37+00:00

In WPF, I want a textbox to throw an event for any and every

  • 0

In WPF, I want a textbox to throw an event for any and every key press while that textbox is focused. I’m not sure of the full extent of what keys aren’t triggering the KeyDown event, but as an example, I know that if I press the left or right arrow, then it doesn’t trigger the event, the cursor just moves left or right respectively. My end all goal is to get the System.Windows.Forms.Keys enum value for any key that was pressed. I already found this question about converting between Key and Keys and now I just need to intercept any and every key. Is there a different event I can respond to like PreviewKeyDown (I’ll be honest, I don’t know the difference between the normal event and the “previewed” event) or is there a property on the textbox sort of like AcceptsTab?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:35:38+00:00Added an answer on May 24, 2026 at 2:35 am

    The PreviewKeyDown-Event is what you need. It is fired before the TextBox has processed key messages and therefore you get an event for all keys.
    If you consume a key in the PreviewKeyDownEvent, you can set the Event.Handled-property to true, and the TextBox will take no more notice from the key.
    You will find the “Preview”-prefix for many events. It is a pattern that is used often. Look here for more information. The interesting part is the “Routing Strategies” section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In WPF , I want to make a TextBox that validates user input to
I want to show a selection in a WPF TextBox even when it's not
I have a WPF TextBox in which I want to allow autocompleting user names
I want my WPF application to have a ToggleButton that contains an image of
My trouble is that I want my WPF ListView to display ListViewItems in different
All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
I want to simulate user input to a WPF TextBox. I want to input
I've to make a textbox(WPF) for entering time with validation. I want to enter
I'm writing a WPF calculator app. In this application I have TextBox that get
How can I set a regular expression on WPF TextBox? I want the textbox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.