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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:06:37+00:00 2026-05-11T12:06:37+00:00

If I know that a certain key has been pressed (eg Key.D3 ), and

  • 0

If I know that a certain key has been pressed (eg Key.D3), and that the Shift key is also down (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)), how can I find out what character that refers to (eg, # on US keyboard, UK pound sign on UK keyboard, etc)?

Put another way, how can I find out, programatically, that Shift + 3 produces # (it wouldn’t on a non-US keyboard).

  • 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. 2026-05-11T12:06:37+00:00Added an answer on May 11, 2026 at 12:06 pm

    If you want to determine what character you will get from a given key with given modifiers, you should use the user32 ToAscii function. Or ToAsciiEx if you want to use a keyboard layout other then the current one.

    using System.Runtime.InteropServices; public static class User32Interop {   public static char ToAscii(Keys key, Keys modifiers)   {     var outputBuilder = new StringBuilder(2);     int result = ToAscii((uint)key, 0, GetKeyState(modifiers),                          outputBuilder, 0);     if (result == 1)       return outputBuilder[0];     else       throw new Exception('Invalid key');   }    private const byte HighBit = 0x80;   private static byte[] GetKeyState(Keys modifiers)   {     var keyState = new byte[256];     foreach (Keys key in Enum.GetValues(typeof(Keys)))     {       if ((modifiers & key) == key)       {         keyState[(int)key] = HighBit;       }     }     return keyState;   }    [DllImport('user32.dll')]   private static extern int ToAscii(uint uVirtKey, uint uScanCode,                                     byte[] lpKeyState,                                     [Out] StringBuilder lpChar,                                     uint uFlags); } 

    You can now use it like this:

    char c = User32Interop.ToAscii(Keys.D3, Keys.ShiftKey); // = '#' 

    If you need more than one modifier, just or them. Keys.ShiftKey | Keys.AltKey

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

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So I went ahead and asked Steve: Alejandro, Our simulation… May 12, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Use a link demand. Decorate your function with something like:… May 12, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer This does not necessarily bear on what humans mean about… May 12, 2026 at 6:20 pm

Related Questions

To save time Googling my website in order to see where my pages have
Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a
I've been using SQL Server for years, so I'm not a noob. I've recently
I'm modding a TextMate bundle even though I'm a complete beginner at Ruby. The

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.