Skip to main content

Use of function keys (F1...F12...ESC key etc) in a form

  • January 30, 2013
  • 1 reply
  • 3 views

What do I need to set up so that I can determine if a function key has been pressed whilst the user is on a Form?

Thanks.

1 reply

Chris Glazier
Forum|alt.badge.img+2

What do I need to set up so that I can determine if a function key has been pressed whilst the user is on a Form?

Thanks.

Trap the KeyDown event on the form.

      method-id Form1_KeyDown final private.
      procedure division using by value sender as object e as type System.Windows.Forms.KeyEventArgs.
|          if e::KeyCode = type Keys::F1
             invoke type MessageBox::Show("F1 was pressed")
             set e::Handled to true
          end-if  
      end method.