473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reassign the Function Keys (F12, etc.)

I'm writing a computer aided dispatching program targeted at security companies. While within certain text box fields, I want to assign the Function keys (F2, F6, etc.) to trigger a search, exit, ...whatever.

This works when I use ASCII character codes with Shift+1 and such, but I can't find an ASCII code for the function keys, nor can I get the code to decode. Additionally, I notice that MS Access uses the function keys to trigger its own shortcuts.

Is there a way I can dissociate the function keys from Access and assign my own functions to them?

Thanks,
Chris Tucker (NO, not that one)
Oct 9 '07 #1
1 12495
missinglinq
3,532 Expert 2GB
VBA has constants for all keys, which makes it easy! Just use them like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourTextBox_KeyDown(KeyCode As Integer, Shift As Integer)
  2.     Select Case KeyCode
  3.  
  4.          Case vbKeyF3
  5.          KeyCode = 0
  6.          MsgBox "F3 Pressed"
  7.  
  8.          Case vbKeyF4
  9.          KeyCode = 0
  10.          MsgBox "F4 Pressed"
  11.  
  12.          Case vbKeyF5
  13.          KeyCode = 0
  14.          MsgBox "F5 Pressed"
  15.  
  16.     End Select
  17.  End Sub
  18.  
Just replace the message boxes with your code of choice. The line

KeyCode = 0

is necessary to suppress Access' native uses for some of these keys. F7, for example, normally invokes SpellChecking and F12 normally invokes Save As. These keys will still work in their normal way except when they're pressed while in the given text box.

Welcome to TheScripts!

Linq ;0)>
Oct 9 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David Hollister | last post by:
Hi all, I have disabled the function keys (F1-F12). I would like each funtion key to submit a form. I'm not quite sure how to tell each function key to submit (post) for me. Any suggestions??...
7
by: Shailesh Humbad | last post by:
I have a class and map like this: class MyObject { ... }; map<int, MyObject> Box; Now, I want to reassign the keys of one or more of the pairs in Box based on another map<int, int> that...
3
by: Armando | last post by:
Apologies if this has been covered recently - I lurked and saw nothing. I have an application that does ticketing at a three-screen movie theatre, and I'm using the function keys F1 thru F12...
2
by: Mike L | last post by:
When the user presses F12, it would be like if the user click on the "Complete" button. In other words, when the user presses F12, I want the code be hide my button's "on_click" to run.
4
by: One | last post by:
hi.. how to get function keys(F1 to F12) when they are pressed? Thankx
12
by: iKiLL | last post by:
Hi I am new to C#, i have come from a VB6 backgrouond. What i am looking for is a list of the Short cut keys for C# and what they do. I am in perticulare looking for the keys to jump to a...
1
by: Sam Samson | last post by:
Greeetings All .. For my users convenience I have mapped function keys F2 .. F12 to change the tabs on the Tabcontrol. Works like a charm <ominous musicuntil one hits F8</ominous music> ...
3
by: =?Utf-8?B?S1NP?= | last post by:
how can i put some text into these key by C# code ? In the old days you could do it by the PROMPT command i DOS but it seems NOT to work any more - the "change key" facility has disappeared. ...
3
by: yogarajan | last post by:
hi All i would like to disable all functional keys(F1 to F12 ) using javascript code. Is it possible? let me know the answer pls response immd
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.