Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

C# lag with e.KeyData.ToString()

This topic is 5186 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm testing a small game I'm making to acclimate myself with C# and to test key input I'm using e.KeyData.ToString() to in my event handler. This is working fine for me save one key. When I set the keyboard input to take "W" "A" "S" and "D" as the input arrows everything works fine but when I use "Up" "Down" etc (the real arrow keys) it lags only when the combination of Up, Down and the Space Bar (shoot) come up. I'm not sure why because when I change only the case "Up" to "W" every bit of lag ceases. Maybe I should mention I'm on a laptop so the keys tend to have other functions but that doesn't make sense to me as the other arrow keys have these as well, not just the up arrow. Any ideas why this happens? You can download the good and bad .exe versions here.
[KrakenDev] [Google: comp.ai.alife] [Corman Lisp Board] [SDL for Corman Lisp] 03.30.03 [edited by - kordova on March 7, 2004 3:46:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
KeyData.ToString() is localization aware, so it will read the string out of some resource assembly. That could be slow.

You should use the constants if you don''t want any delay.
if (e.KeyData == Keys.W)
{
// ...
}

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!