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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:49:48+00:00 2026-06-13T07:49:48+00:00

I want to process the characters typed by the user for a game (I

  • 0

I want to process the characters typed by the user for a game (I don’t want to use an input tag with a submit button).

I managed to get the keyCode typed with this code:

window.on.keyPress.add((Event e) 
{
    window.alert('${e.keyCode},${e.keyIdentifier},${e.charCode}');

});

but I don’t know how to display the character of the key pressed (or even get the character of the key as a string).
In Javascript there is a fromKeyCode() function but not in Dart.

Anyway, I am looking for the simplest way to get the keyboard inputs for processing and I would prefer not have to fiddle with keycodes and such.

  • 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-13T07:49:49+00:00Added an answer on June 13, 2026 at 7:49 am

    You can construct a new string from the character code with String.fromCharCodes().

    var str = new String.fromCharCodes([e.charCode]);
    

    However it’s certainly not the most efficient to be creating a new string each time a user hits a key depending on your game. If you only expect a few specific characters to be hit and ignore others then you may want to create constant/final variables of character codes to compare the character code from the event.

    final E_KEY = "e".charCodeAt(0);
    // ... etc.
    

    Keep in mind these don’t account for various situations such a capitalization, or the CTRL or ALT or meta key pressed, etc.

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

Sidebar

Related Questions

while trying to process some user input which contains characters such as <. I
I have a search query from the user and I want to process it
I want to get the count of characters from the following words in the
No, I don't want to use ncurses , because I want to learn how
I want to process MSXML which is generated by Visio 2010, Which Language will
I want to process large amount of small images on HDFS. Hadoop provides archive
I want to process every element of a for-loop. Taking this code, why is
I want to process a medium to large number of text snippets using a
I want to process a request header using a custom rewrite map. Therefore I
I want to process a file line by line in c, all lines in

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.