How do i use the keyboard in my code?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 10
Reputation: Chris11246 is an unknown quantity at this point 
Solved Threads: 0
Chris11246 Chris11246 is offline Offline
Newbie Poster

How do i use the keyboard in my code?

 
0
  #1
Jul 7th, 2009
im trying to make a little game and i cant find how to use the keyboard to control it what does the code look like?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: How do i use the keyboard in my code?

 
0
  #2
Jul 7th, 2009
For windows application, set KeyPreview property of Form to True and handle key (KeyPress, KeyDown....) events.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 10
Reputation: Chris11246 is an unknown quantity at this point 
Solved Threads: 0
Chris11246 Chris11246 is offline Offline
Newbie Poster

Re: How do i use the keyboard in my code?

 
0
  #3
Jul 7th, 2009
how do i choose which key
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: How do i use the keyboard in my code?

 
0
  #4
Jul 8th, 2009
Set KeyPreview Property of Form1 at design time.

  1. Public Class Form1
  2. Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  3. If e.KeyCode = Keys.F1 Then
  4. MsgBox("F1 is pressed")
  5. Else
  6. If e.KeyCode = Keys.Escape Then
  7. MsgBox("Esc is pressed")
  8. End If
  9. End If
  10. End Sub
  11. End Class
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 10
Reputation: Chris11246 is an unknown quantity at this point 
Solved Threads: 0
Chris11246 Chris11246 is offline Offline
Newbie Poster

Re: How do i use the keyboard in my code?

 
0
  #5
Jul 8th, 2009
thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC