Closed Thread
Results 1 to 3 of 3

Thread: [C] Capture some keys pression

  1. #1
    Alhazred is offline Learning Programmer
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    96
    Rep Power
    0

    [C] Capture some keys pression

    I'm writing a software and for user input I need to avoid the use of some keys, my actual function is this
    Code:
    char * UserInput(int max, int tipo) {
        ...
    	while(!EndInput) {
    	    current = getch();
    	    switch(current) {
    
    	    case VK_RETURN: //ok, capture enter key and do its job
                    ...
                    break;
    
    	    case VK_BACK: //ok, capture backspace and do its job
                    ...
                    break;
    
                case VK_TAB: //ok, makes TAB key do nothing
                    break;
    
                case VK_INSERT: //Don't capture INS key returns òR as output
                    //getch();
                    break;
                    
    	    case 0: //ok, makes functions keys do nothing
                    getch();
    
                case VK_ESCAPE: //ok, capture ESC and do its job
                        ...
    
                default:
                        ...
                        break;
    
            } 
        } 
        return buff;
    }
    In this code is only reported VK_INSERT to not work, but it's the same with VK_PRIOR, VK_NEXT, VK_HOME, VK_DEL, VK_END, VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN
    How could I capture these keys to let them do nothing?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42
    You could make a keyboard hook for your program, which handles all the keys being pressed. This shows you how to install a keyboard hook, and disable the PageDown-key using the hook.

  4. #3
    Alhazred is offline Learning Programmer
    Join Date
    Jul 2007
    Location
    Italy
    Posts
    96
    Rep Power
    0
    I've solved by using a:
    case -32: getch(); break;

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. C# RSA signature with my keys
    By Rinat in forum C# Programming
    Replies: 0
    Last Post: 12-19-2010, 12:51 AM
  2. How do i add the following registry keys
    By iluxon4ik in forum General Programming
    Replies: 2
    Last Post: 03-11-2010, 05:54 PM
  3. Keyboard keys in VB.NET
    By Vswe in forum Visual Basic Tutorials
    Replies: 2
    Last Post: 11-13-2009, 08:18 AM
  4. help with foreign keys
    By the_code_charmer in forum Database & Database Programming
    Replies: 11
    Last Post: 12-11-2008, 12:30 PM
  5. SSH Keys
    By C3P0 in forum Linux Networking
    Replies: 2
    Last Post: 05-27-2007, 03:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts