473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Handling keyboard input

Hi everyone.

For the past day I've been trying to find a good way to handle keyboard input.

Naturally, I wanted to just use WM_KEYDOWN and WM_KEYUP to handle my events, but they proven to have limitations. In my game there was a keyboard delay. If you pressed and held down the right arrow key, the character would move one pixel to the right, stop, then continue moving. I wanted the character to immediately start moving and continue moving once the right arrow key was pressed and held.

Another problem with using just WM_KEYDOWN is that if you are moving your character with the right arrow key and then press spacebar, your character stops moving. Apparently this WM_KEYDOWN message couldn't handle more than one key being processed at a time.

I look into DirectInput and get it working finally. I notice there is none of that keyboard repeat rate delay and it could handle more than one key being held at a time. The problem was, it was messy. Basically, DirectInput was overkill. Also, handling KeyUp messages with DirectInput was hell.

Now I look into GetAsyncKeyState. It looks good, but it seems a bit messy and slow.


Overall, I'm looking for a way to use WM_KEYDOWN and WM_KEYUP to handle more than one key at a time (so if you're moving and press space you don't stop moving for example) and I also want it to not have a delay. For example, the instant I press the right arrow key my character starts moving and doesn't stop.


The only method I found for doing this so far required a messy array of bools I didn't really want to get into. It was worse than using DirectInput or GetAsyncKeyState in my opinion.


Thanks
Aug 9 '07 #1
0 1841

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: =WereWolf= | last post by:
Hi everybody, i'm working with many USB keyboards, which are recognized as HID keyboards on WinXP system. I need to handle input from all those keyboards, and identify the keyboard who is...
0
by: Ray | last post by:
I have English Windows XP Pro and Office 2003 Pro on my computer. When I enter data into fields of tables, queries and forms of Access 2003, it automatically switches to Chinese keyboard input. ...
7
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
0
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
2
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
17
by: Gladiator | last post by:
When I am trying to execute a program from "The C Programming Language" by Dennis Ritchie, I tried to run the following program.I am using Dev++ as a compiler software. The Program is presented...
8
by: BD | last post by:
How can I duplicate the behavior of the operating system shortcut keys in my application? For example, my windows form has 5 controls (textboxes), the operating system will pickup which control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.