943,973 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2007
  • C RSS
Nov 5th, 2009
0

Get keyboard key name?

Expand Post »
I need a function that returns the name of a key directly from the keyboard, eg, the input of '32' would return 'Space'.

I know there is a function that does this, but I can't figure out which one.
Last edited by MajesticMoose; Nov 5th, 2009 at 7:20 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
MajesticMoose is offline Offline
1 posts
since Nov 2009
Nov 5th, 2009
0
Re: Get keyboard key name?
Nope, not as far as I know, you will just have to create a function to return the right values, this could be a start:
  1. string getValueName(char vk) {
  2. string name;
  3.  
  4. if ( vk >= '0' && vk <= '9' ) {
  5. name.push_back( vk );
  6. return name;
  7. }
  8.  
  9. switch ( vk ) {
  10. case VK_SPACE: return "Space";
  11. case VK_SHIFT: return "Shift";
  12. // ... more cases
  13. }
  14.  
  15. return "";
  16. }
Last edited by William Hemsworth; Nov 5th, 2009 at 7:56 pm.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Nov 5th, 2009
0
Re: Get keyboard key name?
I need a function that returns the name of a key directly from the keyboard, eg, the input of '32' would return 'Space'.

I know there is a function that does this, but I can't figure out which one.
I know this is knit picking but....You can't get the name of the key "directly" from the keyboard, its generally via the operating system's kernel....I know knit picking
Reputation Points: 499
Solved Threads: 367
Postaholic
gerard4143 is offline Offline
2,196 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: dynamic Array in C from strings
Next Thread in C Forum Timeline: please help in following data structure programs





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC