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 3216526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:18:18+00:00 2026-05-17T15:18:18+00:00

When handling Control.OnKeyPress event, there is a KeyPressEventArgs that contains a KeyChar . For

  • 0

When handling Control.OnKeyPress event, there is a KeyPressEventArgs that contains a KeyChar.

For usability reasons I need exactly the same KeyChar but when handling OnKeyDown event.

The KeyEventArgs does not contains any char related data. I mean, if press the A key with or without Shift its not affecting the KeyCode, KeyData or KeyValue. The same when using another language, i still getting capital english values.

How to get a KeyPressEventArgs.KeyChar inside KeyDown event?

Thanks.

  • 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-17T15:18:18+00:00Added an answer on May 17, 2026 at 3:18 pm

    Convert it. Here is simple function for converting ‘A’ to ‘a’. It converts only capital chars from [A-Z] set. The value 32 is diff between ‘A’ and ‘a’.. Sure you can extend it to your requirements, or ask for feature here.

    char getChar( KeyEventArgs e )
    {
     int keyValue = e.KeyValue;
     if ( !e.Shift && keyValue >= (int) Keys.A && keyValue <= (int) Keys.Z )
      return (char)(keyValue + 32);
     return (char) keyValue;
    }
    

    if you need it to works with your current culture you should override ProcessKeyMessage Control method:

    protected override bool ProcessKeyMessage( ref Message m )
    {
     if ( ( m.Msg == 0x102 ) || ( m.Msg == 0x106 ) ) // this is special - don't remove
     {
      char c = (char) m.WParam; // here is your char for OnKeyDown event ;)
     }
     return base.ProcessKeyMessage( ref m );
    }
    

    Hope it helpful.

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

Sidebar

Related Questions

I need some advice regarding the handling of a Silverlight control that I need
This question is related to Javascript event handling and flow control , but it
I was handling yet another KeyDown event in a user control when I wondered
I need to implement handling of redelivery of JMS messages in the application that
I am currently handling the KeyDown event of a DataGridView control. One of the
How to handle multiple event in web control using javascript for ex handling onpaste
I have a problem handling a function pointer.I have made a class Control that
I am using PageIndexChanging event for handling GridView paging in C#. But don't know
There are gems/libraries that would benefit from better control over where they inject their
How can i achieve event handling for dynamic controls in VB6? Any ideas?

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.