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

The Archive Base Latest Questions

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

How do you get the VK code from a char that is a letter?

  • 0

How do you get the VK code from a char that is a letter? It seems like you should be able to do something like javax.swing.KeyStroke.getKeyStroke('c').getKeyCode(), but that doesn’t work (the result is zero). Everyone knows how to get the key code if you already have a KeyEvent, but what if you just want to turn chars into VK ints? I’m not interested in getting the FK code for strange characters, only [A-Z],[a-z],[0-9].

Context of this problem ——– All of the Robot tutorials I’ve seen assume programmers love to spell out words by sending keypresses with VK codes:

int keyInput[] = {       KeyEvent.VK_D,       KeyEvent.VK_O,       KeyEvent.VK_N,       KeyEvent.VK_E   };//end keyInput array 

Call me lazy, but even with Eclipse this is no way to go about using TDD on GUIs. If anyone happens to know of a Robot-like class that takes strings and then simulates user input for those strings (I’m using FEST), I’d love to know.

  • 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:45:09+00:00Added an answer on May 11, 2026 at 12:45 pm

    Maybe this ugly hack:

    Map<String, Integer> keyTextToCode = new HashMap<String, Integer>(256); Field[] fields = KeyEvent.class.getDeclaredFields(); for (Field field : fields) {     String name = field.getName();     if (name.startsWith('VK_')) {         keyTextToCode.put(name.substring('VK_'.length()).toUpperCase(),                           field.getInt(null));     } } 

    keyTextToCode would then contain the mapping from strings (e.g. ‘A’ or ‘PAGE_UP’) to vk codes.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Implement a programming language. This doesn't have to be terribly… May 12, 2026 at 8:43 am
  • Editorial Team
    Editorial Team added an answer From Wikipedia's Virtual function ... In object-oriented programming, in languages… May 12, 2026 at 8:43 am
  • Editorial Team
    Editorial Team added an answer Would that mean the could never get bigger than 1… May 12, 2026 at 8:43 am

Related Questions

How do you get the max value of an enum?
How do you get the caret position in a <textarea> using JavaScript? For example:
How do you get the current directory where your app is running?
How do you get the logical xor of two variables in Python? For example,

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.