LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 605 users online 173669 members 850 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Video | Dictionary | News | FAQ
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
2 online / 83 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

C# KeyPresses
Replies: 1Last Post Dec. 7, 2007 6:07am by obvious Troll
Single page for this topic Email Print Favorite
( obvious Troll )

Advisor
Reply
I'm making Tetris. The thing is, I've gotten all the hit detections and shit working. Now the next thing to do is to set it to move on a mouse button. Since we are getting ready for a Java AP test, we are not allowed to use any form designers. I've put in this code form Form1_Load:

Code:
this.KeyDown += new System.Windows.Forms.KeyEventHandler(Steering);

Code:
private void Steering(object sender, KeyEventArgs e)
       {
           Console.WriteLine("KeyData: " + e.KeyData);
           Console.WriteLine("KeyCode: " + e.KeyCode);
           Console.WriteLine("KeyValue: " + e.KeyValue);
       }

In the function Steering, on Key Press it's supposed to echo in the console the key data. However, nothing occurs when I press a key. I'm assuming what I'm doing wrong is that the buttons, that act as the tetris blocks, are being active and not the form. Any ideas to fix?

-------
Obvious Troll! Always a right decision!
I'll be here to /halp/ you. Just not emos.


5:38 pm on Dec. 5, 2007 | Joined Nov. 2007 | 11 Days Active
Join to learn more about obvious Troll Florida, United States | Straight Male | 410 Posts | 454 Points
( obvious Troll )

Advisor
Reply
Problem solved, please lock.

In case anyone experiences the same problem, on FormX_Load (or any other place where the form loses commitment), place this:
Code:
this.Activate();


-------
Obvious Troll! Always a right decision!
I'll be here to /halp/ you. Just not emos.


6:07 am on Dec. 7, 2007 | Joined Nov. 2007 | 11 Days Active
Join to learn more about obvious Troll Florida, United States | Straight Male | 410 Posts | 454 Points
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic