Results 1 to 2 of 2

Thread: Two keys pressed, GLUT

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Posts
    1

    Two keys pressed, GLUT

    Hello, i'm using GLUT 3.7
    with the KeyboardFunc call i call a function which recieves only 1 key, and two coordinates (x,y). how can i make my program deal with more than one key pressed at a time?
    let's say i have a model rendered and i would like to move it both up and left (diagonaly). when i press up it goes up but as soon as i press the left button while the up is pressed - it moves only to the left...

    hope you can help...

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Two keys pressed, GLUT

    Firstly, Id advice against using GLUT for much beyond simple demos... But anyway.
    What you have to do, is account for both KeyUp and KeyDown events. So when a key is pressed, you mark it as pressed, and then when that key is released, a keyup event will be issued by glut, and just mark that key as not pressed.
    At the moment your probably only using the keydown event, which is why you cant handle more than 1 key at a time.

    [This message has been edited by MrShoe (edited 02-14-2004).]

    [This message has been edited by MrShoe (edited 02-14-2004).]
    :: Sleep is a poor substitute for caffeine ::

Similar Threads

  1. Issue with multiple keys pressed
    By thor4000 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-08-2018, 05:21 PM
  2. GLUT: mouse stops when a key is pressed?
    By Omarius in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-09-2015, 12:53 PM
  3. Keys in GLUT
    By LordOfTheUniverse in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-16-2002, 12:07 PM
  4. Running a function with two keys pressed at the same time.
    By Tazz FTAlliance in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-08-2002, 10:24 PM
  5. Glut Keys?
    By dabeav in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-06-2002, 08:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean