8 Replies - 5712 Views - Last Post: 29 October 2006 - 08:55 PM Rate Topic: -----

#1 NyeNye  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 24-September 06

press keys

Posted 27 October 2006 - 03:20 AM

If how could i modify a hot keys for example i want to quit a program i just press q for

exiting the programs how could i do that???
Is This A Good Question/Topic? 0
  • +

Replies To: press keys

#2 ihatepikingnames  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 119
  • Joined: 31-July 06

Re: press keys

Posted 27 October 2006 - 08:29 AM

My bad... wrong window

This post has been edited by ihatepikingnames: 27 October 2006 - 08:32 AM

Was This Post Helpful? 0
  • +
  • -

#3 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Re: press keys

Posted 27 October 2006 - 08:42 AM

Youd have to use a scan or listen to the keyboard input and if 'q' then exit kind of thing. post your code and we can help a more with your problem.
Was This Post Helpful? 0
  • +
  • -

#4 NyeNye  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 24-September 06

Re: press keys

Posted 28 October 2006 - 06:05 AM

i just wanna get your idea...

to how it would be...
Was This Post Helpful? 0
  • +
  • -

#5 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: press keys

Posted 28 October 2006 - 09:00 AM

if(myvar=='q')
   exit(1);


is probably the simplest example, but may not be what your looking for as the original information is not complete. Are you prompting for input? Scanning or polling?
Was This Post Helpful? 0
  • +
  • -

#6 CBart21  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 21
  • Joined: 28-October 06

Re: press keys

Posted 28 October 2006 - 09:03 AM

string exitVar;
getline(cin, exitVar);
if (exitVar == "q") exit(0);



Hope that works.
Was This Post Helpful? 0
  • +
  • -

#7 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Re: press keys

Posted 28 October 2006 - 01:02 PM

Maybe im wrong, but doesnt Cbarts code require them to press enter? I was under the impression they want to listen for it instead of having the user press enter after it, in other word, not being prompted for it.
Was This Post Helpful? 0
  • +
  • -

#8 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: press keys

Posted 28 October 2006 - 01:07 PM

CBart's code does require an enter key, and will not work if the user is expecting to auto detect any key press. That's why I'd asked the user to be a little more clear on what they're looking for - simple user prompts, or a method to poll the keyboard (I suspect the latter).

That being said, much will also depend on what type of application it is, and what is used to implement it (console,MFC,Win32,many others).
Was This Post Helpful? 0
  • +
  • -

#9 NyeNye  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 24-September 06

Re: press keys

Posted 29 October 2006 - 08:55 PM

for example i press my assign letter from my keyboard then it excute the method that i aasign on it....

just example:

if i had a program...

with certain commands...and functions....
[q]uit
[p]layer
[s]elect

if i press q,p,s, or any.....on my declaration it exute the methods for that.....

This post has been edited by NyeNye: 30 October 2006 - 10:00 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1