Solved

Hotkey independent of what has the control focus

Posted on 2004-08-04
3
288 Views
Last Modified: 2010-05-18
I need to know how to have a hot key execute a sub routine or function regardless of what control has the focus. Functionally, what I want is very similar to when you assign CTRL-N to a menu.

The software is a point of sale system, and I need the user to be able to press "c" and have the credit card dialog pop up, or the "t" key and have the "tender bill" dialog come up.

Any thoughts?
0
Comment
Question by:DrDamnit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 11723170
You can use HotKey (an example of mine below):
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_21047290.html

..or just do it through form-level. A form's KeyPreview property allows keydown events to be passed to the form even if another control has focus.

Example:
-------------
Option Explicit
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyF1 Then
        Call MsgBox("F1 was pressed.")
    End If
End Sub
Private Sub Form_Load()
    Me.KeyPreview = True
End Sub
0
 
LVL 5

Expert Comment

by:cristy56
ID: 11723176
0
 
LVL 32

Author Comment

by:DrDamnit
ID: 11730723
Keypreview did it!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question