473,382 Members | 1,329 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,382 software developers and data experts.

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
3 2885
johny10151981
1,059 1GB
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
donbock
2,426 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
Banfa
9,065 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

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

Similar topics

2
by: Fred Snider | last post by:
Help! Opening a new window using the window.open( ) command works great for opening new windows and having them on top and having the focus. The window.focus command brings any existing...
4
by: jdlwright | last post by:
Hi, well it appears (and please please correct me if I am wrong) that since some IE patch (I am using 6.0.2800.1160 SP2) the browser no longer calls the onunload handler when running outside of...
4
by: Ralf Toender | last post by:
Hi! Does anybody know how to send a keystroke C#? In C++ it's done by: keybd_event ( ... ) or SendInput ( ... ). What namespace does include this counterpart? Thanks Ralf
5
by: academic | last post by:
Hate to ask such a simple question but I've been looking through Help and can't find what I need. If I need to abort the app I print a message (fprintf) and return -1 Between those two I'd...
2
by: pelletier.thomas | last post by:
Hello everybody. I'm trying to code a very little OS. But I have a problem with the keyboard input: It show thechar + "~" :s Can you help me ? The source is there :...
0
by: Srin | last post by:
Hi, I'm in the process of writing a small C# App, in which i have two groupboxes in a form. The form has the KeyPreview property set to true. The groupbox1 contains a set of labels. The second...
4
by: Jason | last post by:
Hi, Here's the scenario: I have a web application that has window A and window B. A user has both window A and B open - window A is in the foreground and window B is behind it. If the...
4
by: Spizzat2 | last post by:
I'm trying to figure out a workaround to a minor annoyance that I'm coming up with while coding a site. I've got some keyboard shortcuts set up for the site via javascript, and when I press escape,...
3
by: =?Utf-8?B?cHJvZ2dlcg==?= | last post by:
I have a C# application that hosts an AxWebBrowser control which I automate by sending mouse clicks and keyboard input. I have had various problems in doing this due to a bug in the AxWebBrowser...
5
by: bint | last post by:
Please help. Trying to just get simple keyboard input from a C program. Ideally would like to be able to just press a key without having to press return, but at this point I don't care anymore. I...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.