473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Detecting a key from the ASCII character set

Hello,

I have a KeyDown event in which I would like to determine if the current key
is a standard character (i.e., from the ASCII character set). In C I would
use something like the isascii finction for this, but I realize the key
values produced by the Keys enumeration are not simply the ASCII value of the
keys. I've found references to the IsInputKey method but I can't fiture out
how it is used (or if it should be used) for this purpose in my KeyDown event
handler. My only other thought is to individually test the value of the
KeyCode against each key value I am willing to accept, but this is much to
brutal and I'm sure, inappropriate.

Thanks,
Ray
Apr 23 '07 #1
1 2246
"Ray Mitchell" <Ra*****************@MeanOldTeacher.comwrote in message
news:AE**********************************@microsof t.com...
Hello,

I have a KeyDown event in which I would like to determine if the current
key
is a standard character (i.e., from the ASCII character set). [...]
My only other thought is to individually test the value of the
KeyCode against each key value I am willing to accept, but this is much to
brutal and I'm sure, inappropriate.
The KeyDown event doesn't tell you much at all about the character being
entered. It tells you which physical key is being pushed. This can be
converted to a specific character code, of course, but the event is really
more for situations where the specific key being pushed is interesting to
you.

If you want a more character-oriented input scheme, you may want to consider
looking at the KeyPress event instead. That will return ASCII values, which
you can then check for inclusion as a "standard character" (however you
choose to define that).

The IsInputKey() method is not really relevant, I think. It is more useful
if you already have code that determines whether the KeyDown event
corresponds to a key that would not normally be considered an input key, but
which you would like to for some reason. You can override it and then
return true if you don't want the key preprocessed (for example, if you have
a text-editing control and you want tab characters to be entered into it
instead of having the focus changed).

Pete

Apr 23 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Daniel | last post by:
Hi, is there a way to check if a letter entered is an uppercase ASCII character? Thanks Daniel
19
by: Ian | last post by:
I'm using the following meta tag with my documents: <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> and yet using character entities like &rsquo; and &mdash; It...
3
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
11
by: Kai Bohli | last post by:
Hi all ! I need to translate a string to Ascii and return a string again. The code below dosen't work for Ascii (Superset) codes above 127. Any help are greatly appreciated. protected...
5
by: Z.K. | last post by:
In C#, using the StreamReader, how do I detect when you get to the end of line. I am reading a text file using the Read() function and I need to detect the \n\r, but everything I try does not...
9
by: simchajoy2000 | last post by:
Hi, I know what the ASCII Character Codes are for the 2nd and 3rd powers in VB.NET but I can't find the 6th power anywhere - does anyone know what it might be or if it even exists? Joy
9
by: =?Utf-8?B?RGFu?= | last post by:
I have the following code section that I thought would strip out all the non-ascii characters from a string after decoding it. Unfortunately the non-ascii characters are still in the string....
44
by: Pilcrow | last post by:
Is there a way that a proram can detect whether it is operating in an ASCII or an EBCDIC environment?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.