LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 430 users online 224743 members 1593 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Databank
Movies: Black Hawk Down
Mood: Scheming
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
4 online / 24 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Adding Reply

Adding Reply
Archived Topic: It will not be bumped to the top of the forum.
Topic C# KeyPresses
Membername   Not a member? Sign Up Free (takes 20 seconds)
Password   Forgotten your password?
Post

Font:   Size:   Color:

FAQ Keyword Search:
Post Options
Favorites Manager
Notify me of new replies to this topic by email
Notify me of new replies to this topic by private message
Original Post
obvious Troll Posted at 5:38 pm on Dec. 5, 2007
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?

Replies
obvious Troll Posted at 6:07 am on Dec. 7, 2007
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();