467,886 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,886 developers. It's quick & easy.

Keyboard input via getchar() only works when window in focus

my program gets keyboard inputs using getchar(). My code executes, and the program runs fine, providing the desired gui. It runs on puppy linux on an Eee PC. However, the keyboard input, which I use to control a few functions only works when I have a terminal open on top of the program window, and the terminal is the focus. When the terminal is not the focus, or if I do not execute the program from the terminal, the key input does not work. Is this a system problem or a C problem? I have the usual includes, termios, stdio. Can anyone suggest a fix?
May 21 '11 #1
  • viewed: 2631
3 Replies
This is neither C problem nor System problem. Its problem of design and plan. getchar is a standard I/O function and the standard I/O is console(terminal). Design the software more cleverly............
May 21 '11 #2
Expert 2GB
It is entirely possible that somebody might run several other programs at the same time that they are running yours. Focus refers to which one of these many programs is currently connected to the keyboard. You actually want your program to be unaware of keyboard input while it doesn't have focus.
May 21 '11 #3
Expert Mod 8TB
I don't know which library you use to create your gui but it will almost certainly have a method apart from getchar that will allow you to capture keyboard input.

You should be using that method and not getchar.
May 23 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Ralf Toender | last post: by
2 posts views Thread by pelletier.thomas | last post: by
4 posts views Thread by Spizzat2 | last post: by
3 posts views Thread by =?Utf-8?B?cHJvZ2dlcg==?= | last post: by
5 posts views Thread by bint | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.