You can use the htmlpage object htmlpage (system. Windows. browser ;)
Htmlpage. Window. attachevent ( " Dommousescroll " , Onmousewheel );
Htmlpage. Window. attachevent ( " Onmousewheel " , Onmousewheel );
Htmlpage. Document. attachevent ( " Onmousewheel " , Onmousewheel );
Private VoidOnmousewheel (ObjectSender, htmleventargs ARGs)
{
}
Then we will get a rotation angle attribute in the onmousewheel method.
However, the name of this attribute varies in different browsers.
From this angle, we can know that the mouse is rolling up or down.
Double Mousedelta = 0 ;
Scriptobject E = Args. eventobject;
If (E. getproperty ( " Detail " ) ! = Null )
{ // Firefox and Apple
Mousedelta = (( Double ) E. getproperty ( " Detail " ));
}
Else If (E. getproperty ( " Wheeldelta " ) ! = Null )
{ // IE and opera
Mousedelta = (( Double ) E. getproperty ( " Wheeldelta " ));
}
Mousedelta = Math. Sign (mousedelta );
If (Mousedelta > 0 )
{
TXT. Text = " Scroll up " ;
}
Else If (Mousedelta < 0 )
{
TXT. Text = " Scroll down " ;
}
When you scroll up or down, you can add the mouse coordinates to determine which control the mouse is on. Different operations can be performed.
Next, let's talk about how to obtain the keyboard keys (for example, we often press Ctrl + mouse or Ctrl + enter)
In fact, we only need to use an enumeration value.
Namespace System. Windows. Input
{
// Summary:
// Specifies the set of modifier keys.
[Flags]
Public Enum Modifierkeys
{
// Summary:
// No modifiers are pressed.
None = 0 ,
//
// Summary:
// The ALT key is pressed.
ALT = 1 ,
//
// Summary:
// The ctrl key is pressed.
Control = 2 ,
//
// Summary:
// The shift key is pressed.
Shift = 4 ,
//
// Summary:
// The Windows logo key is pressed.
Windows = 8 ,
//
// Summary:
// The apple key (also known as the "Open apple key") is pressed.
Apple = 8 ,
}
}
Methods
Like registering a click event on the current page
This . Mouseleftbuttondown + = New Mousebuttoneventhandler (page_mouseleftbuttondown );
Void Page_mouseleftbuttondown ( Object Sender, mousebuttoneventargs E)
{}
We need to perform a few operations in it to determine whether the user is still holding down a key on the keyboard.
Modifierkeys keys = Keyboard. modifiers;
TXT. Text = "" ;
If (Keys & Modifierkeys. Shift) ! = 0 )
TXT. Text + = " Shift " ;
If (Keys & Modifierkeys. alt) ! = 0 )
TXT. Text + = " ALT " ;
If (Keys & Modifierkeys. Apple) ! = 0 )
TXT. Text + = " Apple " ;
If (Keys & Modifierkeys. Control) ! = 0 )
TXT. Text + = " CTRL " ;
If (Keys & Modifierkeys. Windows) ! = 0 )
TXT. Text + = " Windows " ;
TXT. Text + = " + Mouse clicks "