-
Hi,
I have a container with a several input fields (controls) on a web page. This has to act like a standalone app within the browser. One thing I want is, when the page loads, the user should be able to hit a function key and a vbscript on the page will redirect to another jsp page.
When I have an exe control, this is easy because the form can catch all of the key presses. But how can I set this up when I'm on a web page? Should my listener be in the container code?
Any help would be really appreciated,
Mike
-
Use the GetAsyncKeyState api function and put this code in a timer, and it will capture everything typed.
Code:
Private Declare Function GetAsyncKeyState _
Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_Load()
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
For i = 3 To 255
If GetAsyncKeyState(i) Then Debug.Print Chr(i)
Next
End Sub
-
Matthew,
This is a huge help -- thanks so much. It looks like you're extremely confortable with this stuff; could I ask two more questions?
I can capture keystrokes now, but I also need to capture keystroke combinations, e.g. Alt-S. I understand how to register a hot key, so all I should need to do is register my combination and then listen for it in my timer listener routine, right? How exactly should the code look for referencing this event; obviously GetAsyncKeyState won't do.
My second and probably dilemma is, when I receive the right key I'm listening for, I need vbscript on the web page to do a redirect. How do I listen for my keystroke event on the page? I can raise an event right but then how is this event referenced on the page, i.e. how can I set up my properly declared control_event() routine?
Sorry to bother you again,
Mike
-