How to detect Page Down/Page Up keys, etc.

  • Thread starter Thread starter foo
  • Start date Start date
F

foo

Hello,

I can trap alphanumeric keys wih this code but the event doesn't even fire
when a page down, page up, home, end is pressed. I've overloaded the
OnKeyPress event for the form. The event will fire on alphanumeric keys,
punctuation, etc. Why won't the event fire on Page Up/Page Down keys?
Protected Overrides Sub OnKeyPress(ByVal e As
System.Windows.Forms.KeyPressEventArgs)

Select Case Val(e.KeyChar())

Case Keys.PageDown ' Page Down

....

end function



Thanks,

Bill Nicholson

Cincinnati, OH, USA
 
foo said:
I can trap alphanumeric keys wih this code but the event doesn't
even fire
when a page down, page up, home, end is pressed. I've overloaded
the OnKeyPress event for the form. The event will fire on
alphanumeric keys, punctuation, etc. Why won't the event fire on Page
Up/Page Down keys? Protected Overrides Sub OnKeyPress(ByVal e As
System.Windows.Forms.KeyPressEventArgs)

Select Case Val(e.KeyChar())

Case Keys.PageDown ' Page Down

...

end function

These keys don't create chars. Use OnKeyDown instead.
 
I can trap alphanumeric keys wih this code but the event doesn't even fire
when a page down, page up, home, end is pressed. I've overloaded the
OnKeyPress event for the form. The event will fire on alphanumeric keys,
punctuation, etc. Why won't the event fire on Page Up/Page Down keys?

For the other keys, you need to override the OnKeyDown method.
 
Back
Top