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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:14:24+00:00 2026-06-06T10:14:24+00:00

I have to work with a string standing for a keystroke (for instance A,

  • 0

I have to work with a string standing for a keystroke (for instance “A”, “ENTER”, “F4”). From this string I need to get the keychar, the keycode and the key modifiers for the keystroke.

Here is what I do (for F4 for example) :

AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke("F4");
System.out.println(ks.getKeyCode());
System.out.println(ks.getKeyModifiers());
System.out.println(ks.getKeyChar());

I get :

115
0
?

keycode and modifiers are OK but whatever keystroke I try I always get ? for the keychar …

Am I missing something ?

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

    2 comments:

    • you don’t specify that you typed the key, in which case pressed is assumed and no character is printed
    • there is no valid unicode character for “F4”

    If you change your statement to System.out.println((int)ks.getKeyChar()); you will see that keyChar is 65535, which is the value of KeyEvent.CHAR_UNDEFINED.

    You could try AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke("typed A"); to see that keyChar is A and you could also try AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke("typed F4"); to see that you get an exception.

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

Sidebar

Related Questions

I can't get this to work.. I have an String which I want to
I have a string in which I need to replace markers with values from
In my work I have with great results used approximate string matching algorithms such
I have to work with strings which may contain Lat/Long data, like this: $query
I am trying to get this to work I am using this code and
I have a question. I have a work this morning but i don't know
I have array defined like this : ArrayList<String> items = new ArrayList<String>(); I have
I have home work for parsing XML This is the xml : <?xml version=1.0
I have a string (which is a message) that I get as input and
The setup of what i have to work with and what i need is

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.