473,503 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

KeyPressed function?

Hi!

A newbie question: How can I check, whether a key has been pressed and
take that input to perform some action? I don't want to wait for that
input (=> no Enter needed) and the input should not be displayed.

Tnx a lot

Karl
Jul 22 '05 #1
7 4560
Karl Ebener wrote:

Hi!

A newbie question: How can I check, whether a key has been pressed and
take that input to perform some action? I don't want to wait for that
input (=> no Enter needed) and the input should not be displayed.


There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.


Could you give me a hint for Linux systems? I looked but didn't find
anything....

Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}

Tnx
Karl
Jul 22 '05 #3
Karl Ebener wrote:
Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.


Could you give me a hint for Linux systems? I looked but didn't find
anything....

Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}

You can return arrays, but doing so requires you to use new[] and
delete[] and deal with the memory management yourself.

A much better idea would be to use "vector" or "list", which are classes
provided by c++ which are much easier to deal with than plain arrays.
Look them up in any good (or even most bad) C++ books :)

Chris
Jul 22 '05 #4
Karl Ebener wrote:

Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.

Could you give me a hint for Linux systems? I looked but didn't find
anything....


Sorry. I donÄt know about Linux. You should ask in a newsgroup dedicated
to Linux programming.

Another question: Is there a way to make a function return a list?
e.g.
int[] abc() { //*returning list*}


int[] is not a list.
It is the notation for an array with unknown dimensions. But
beware, in this case things are not what they seem to be. The
above is in reality a way to avoid pointer notation, nothing
more. And it cannot be used as return type.

As for a list:

#include <list>

std::list<int> foo()
{
list<int> MyList;

MyList.push_back( 5 );
MyList.push_back( 7 );

return MyList;
}

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #5
Karl Ebener wrote:
Hi!
There is nothing in standard C++ to help you.
Mostly because standard C++ is not aware of a keyboard.
All input or output is generalized to a stream.

But that doesn't mean that it can't be done on your
specific system. All it means is that there is no
general solution. You need system specific functionality
to do that.


Could you give me a hint for Linux systems? I looked but didn't find
anything....


You can try the GNU readline library.

-Arijit
Jul 22 '05 #6
Karl Ebener wrote:
Could you give me a hint for Linux systems? I looked but didn't find
anything....


Most likely something in the curses library. An excellent place to
start is comp.unix.programmer.


Brian
Jul 22 '05 #7
Karl Ebener wrote:

How can I check, whether a key has been pressed
and take that input to perform some action?
I don't want to wait for that input (=> no Enter needed)
and the input should not be displayed.


Take a look at
The Linux Keyboard HOWTO

http://web.inet-tr.org.tr/Online/Lin...ard-HOWTO.html

Read

/usr/include/linux/keyboard.h

Read the man pages for showkey, dumpkeys and loadkeys.
Jul 22 '05 #8

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

Similar topics

3
14906
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
5
2808
by: phil_gg04 | last post by:
Dear Javascript Experts, Opera seems to have different ideas about the visibility of Javascript functions than other browsers. For example, if I have this code: if (1==2) { function...
2
7661
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
2
12663
by: sushil | last post by:
+1 #include<stdio.h> +2 #include <stdlib.h> +3 typedef struct +4 { +5 unsigned int PID; +6 unsigned int CID; +7 } T_ID; +8 +9 typedef unsigned int (*T_HANDLER)(void); +10
2
2611
by: active | last post by:
I have a picturebox usercontrol sitting on a usercontrol. I need a KeyPress event in the PictureBox. I suppose I could have a property in the pictureBox that is accessed by a call in a...
6
3349
by: Shirenseru | last post by:
Hi, I recently saw on a website, that there was a possibility that when you're on a certain webpage, and you type like " code " on your keyboard, that some function is being called. Does...
2
2848
by: Memborg | last post by:
Hej Everybody I have tried do make an "instant search" in javascript, ie everytime one hits a key the javascript sends the request to a database and returns the result into a table. The...
2
4904
by: Peter Newman | last post by:
vb.net 2003 i have the following procedure Private Sub StrLicence_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles StrLicence.KeyPress Select Case...
4
2781
by: pinkfloydhomer | last post by:
I need a function (blocking or non-blocking) that tells me if a key has been pressed (even before it has been released etc.). Also, I would of course like to know _which_ key has been pressed. I...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
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
7467
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...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.