Problem with key registering

Hi guys i have problem with key registering.So i have a program that registering every key press from a-z and 0-9 so i make them but when i press and hold key they registering something like "aaaaaaaaaaa" so i need to make it if i click on key it write one time i was make it with Sleep(); but it's too slow and if i write fast they mixing letters Something like "word"= "woddr" or something like that. Any suggestions? (im using while loop).
Use a container that allows unique entries only like std::set or std::map (depends on what data you want to store).
pseudocode:

once
static char last = get key press from hardware
log(last)
end once

every other iteration
current = get key press
if current != last
log(current);
last = current;

this of course is not logging every key press at that point.
in windows, you can use .net tools to check key-down and key-up states rather than the stream of chars. That sort of thing may be a better approach. The reason is that if I type bool it would log bool, as most people typing hit the o twice, not try to hold it down to get exactly 2 of them, but someone playing a game using wasd movement would hold the w down for 2 min straight....
Last edited on
Topic archived. No new replies allowed.