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

  • SEARCH
  • Home
  • 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 8212449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:45:44+00:00 2026-06-07T10:45:44+00:00

Consider this basic TextBox in WPF: <TextBox Name=textBox1 KeyUp=textBox1_KeyUp /> And the event: using

  • 0

Consider this basic TextBox in WPF:

<TextBox Name="textBox1" KeyUp="textBox1_KeyUp" />

And the event:

using System.Diagnostics;
...
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{ Debug.WriteLine(textBox1.Text + "; " + e.Key.ToString()); }

If I type slow in the TextBox the output is:

t; T
te; E
tes; S
test; T

But if I type fast, the output is wrong (note the S already in textBox1.Text when processing key E):

t; T
tes; E
test; S
test; T

I want to process the correct e.Key (the last pressed). It seems to me that the event is not updated as fast as the TextBox.Text property. Is there a way to solve this problem?

  • 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-06-07T10:45:46+00:00Added an answer on June 7, 2026 at 10:45 am

    The reason you see this behavior is because the contents of the TextBox are updated shortly after the KeyDown event occurs. When typing very fast it’s possible to do it in the following order

    • KeyDown: T
    • KeyUp: T
    • KeyDown: E
    • KeyDown: S
    • KeyUp: E
    • KeyUp: S

    If you want to process the last key which was pressed down in the KeyUp event you would have to listen to KeyDown and store the value somewhere between the events. I wouldn’t recomend that though as you can get key events in many orders you wouldn’t expect (especially on non-English keyboards). I would stick with handling the event in KeyDown or KeyUp.

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

Sidebar

Related Questions

Consider this simple example - public class Person { private String name; private Date
For ease of discussion, consider this basic table (Test) in Access... ID division name
This is a very basic question, so please bear with me. Consider the following
Let's consider this basic insert insert into TableName (Col1,Col2,Col3) values (Val1,Val2,Val3) i want this
Consider the following class class A{ public void init(){ //do this first; } public
Let's consider this page's code-behind: public partial class Products : Page { private static
Consider this class: @Entity class Bar { @Id private long id; private FooId fooId;
I have a couple of basic questions on parametrized queries Consider this code: $id
Consider this code: enum { ERR_START, ERR_CANNOTOPENFILE, ERR_CANNOTCONNECT, ERR_CANNOTCONNECTWITH, ERR_CANNOTGETHOSTNAME, ERR_CANNOTSEND, }; char* ERR_MESSAGE[]
Consider this contrived, trivial example: var foo = new byte[] {246, 127}; var bar

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.