Advertisement

VK_TILDE???

Started by August 24, 2000 09:29 PM
11 comments, last by wise_Guy 24 years, 3 months ago
Does anyone know what the Virtual Key Code for the tilde (~) key is? I can''t find it in the MSDN documentation, but then again I am finding that slightly cryptic at the moment. Thanks all wise_guy
Maby you can use the ASCII value, which is 126.
AquDev - It is what it is.
Advertisement
Or ''~'' (maybe it''s ''\~'') to be portable
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Ummm... the ascii value of 126 is not working. I am using the WM_KEYDOWN windows message, so maybe it doesn''t just send plain ascii values...

Anyway, I checked the MSDN and it says that the ascii is 96 for the ~ key... but anyway, the message doesn''t just send ascii values i''m pretty safe in assuming.

Anyone know what windows likes to call this key?


wise_guy
Well, that''s what happen when you ''Assume'' things.

    case WM_KEYDOWN:            switch (wParam)            {                case VK_ESCAPE:                case VK_F12:			 PostMessage(hWnd, WM_CLOSE, 0, 0);                    return 0L;		case ''~'':                     do something;                     break;           } 			    


''~'' returns the exact ASCII value of ~, it works, and
That''s a fact.



hey, well what if i wanted an alt-''~'' ?
Advertisement
quote: Original post by Anonymous Poster


hey, well what if i wanted an alt-''~'' ?


- Why not use an accelerator resource?
- Maybe GetAsyncKeyState(), GetKeyState() or GetKeyboardState() is what you''re looking for...

96 is the ASCII value of the '`' Character... so maby the KeyDown doesn't send actual ASCII values, but symbolic ones...

For example, for the c character, you'd use 'C' (captial), which has a diffrent value then 'c', ofcourse.

Edited by - Aqutiv on August 28, 2000 1:09:44 PM
AquDev - It is what it is.
Okay, where to begin?

to the first anon poster - that doesn''t work. I have tried it and it doesn''t work.

to aqutiv - yes that''s what I''m thinking! The actual value that the ~ or ` key sends in the wparam of the WM_KEYDOWN message is actually 192 according to my keyboard. See, I copied wparam to an integer and printed that integer to the screen. For all the letters, the enter, the spacebar, it returned the ascii code, but for some keys, including the tilde, it didn''t.

Anyway, to summarise, on MY keyboard, at least, the windows code for tilde (~) is 196.


wise_guy
ASCII tables are not keyboard dependant... They''re roughly OS and/or language dependant.

But basically, It is universal.. If it wasn''t, people wouldn''t be able to read what I''m writing right now!

To understand this, Maby you should read a tutorial about binary and ASCII files and their difrences.

ascii files are actually binary files in their uniqe way, They''re made of chars, which as you probably know are bytes,
(which are 8bit), each byte represents a number from 0 to 255, That number is the ASCII value, the program that reads the text file translates each byte using an ASCII table into its appropiate character.. That''s why you get weird junk when reading binary files, because the program blindly gets each byte and translates into a character, even though the information is most of the time numeric and not text.
The last character in every text file is the NULL terminator, which has the value of, hrrrm, 0. New lines are probably an exception because they differ from OS to another.. for example, on Win32, it''s the character 10 (\r - carriage return) followed by 13 (\n - the new line character). On linux, it''s just 13.










AquDev - It is what it is.
AquDev - It is what it is.

This topic is closed to new replies.

Advertisement