Results 1 to 4 of 4

Thread: Simultaneous key presses

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    CA
    Posts
    3

    Simultaneous key presses

    Hi,

    I'm currently coding a 3D engine in C and using GLUT to maintain maximum portability.

    How do you allow for simultaneous key presses? For example, when I'm moving forward and then I want to strafe, I need to press the 'forward' button, let go, then press 'strafe' button. is there a way to handle button presses better without having to let go?

    also, is there a platform-independent way to detect if you have RELEASED a key button? this would be very helpful to trigger deceleration in a 3D engine so your player doesn't just stop instantaneously.

    thanks.

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Simultaneous key presses

    Q2: use glutKeyboardUpFunc()

    Q1: I've never had any problems with simultaneous keypresses in GLUT. Just associate a flag with each control key, set it to true in glutKeyboardFunc and to false in glutKeyboardUpFunc(). Then base your movement on the combination of the various key flags.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2000
    Location
    CA
    Posts
    3

    Re: Simultaneous key presses

    thanks a lot for your help. much appreciated.

    btw, how did you know about glutKeyboardUp()?

    i did not find that in the GLUT API.

    thx.

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Simultaneous key presses

    Heh... get into the habit of reading the headers. The GLUT API docs aren't particularly up-to-date.

Similar Threads

  1. How to use multiple simultaneous depth units?
    By zrzmonkey in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-17-2011, 02:28 AM
  2. Jumping Physics I got. Key Presses I dont!!
    By Edward472 in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 11-10-2010, 07:55 PM
  3. Simultaneous Lighting and Blending impossible?
    By Nick Nougat in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-30-2002, 05:15 PM
  4. catching double keyboard presses exception
    By in forum OpenGL: Linux
    Replies: 10
    Last Post: 04-20-2002, 04:17 AM
  5. Multiple Keyboard presses?
    By in forum OpenGL: Linux
    Replies: 5
    Last Post: 02-26-2001, 08:17 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