Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-24-2015, 03:40 PM
macropod's Avatar
macropod macropod is offline Show Key Combination Pressed by User Windows 7 64bit Show Key Combination Pressed by User Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In Windows, you might use userform code like:
Code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Dim strMask As String, StrKey As String
Select Case Shift
  Case 1: strMask = "Shift+"
  Case 2: strMask = "Ctrl+"
  Case 3: strMask = "Ctrl+Shift+"
  Case 4: strMask = "Alt+"
  Case 5: strMask = "Alt+Shift+"
  Case 6: strMask = "Ctrl+Alt+"
  Case 7: strMask = "Ctrl+Alt+Shift+"
  Case Else: strMask = ""
End Select
Select Case KeyCode
  Case vbKeyF1: StrKey = "F1"
  Case vbKeyF2: StrKey = "F2"
  Case vbKeyF3: StrKey = "F3"
  Case vbKeyF4: StrKey = "F4"
  Case vbKeyF5: StrKey = "F5"
  Case vbKeyF6: StrKey = "F6"
  Case vbKeyF7: StrKey = "F7"
  Case vbKeyF8: StrKey = "F8"
  Case vbKeyF9: StrKey = "F9"
  Case vbKeyF10: StrKey = "F10"
  Case vbKeyF11: StrKey = "F11"
  Case vbKeyF12: StrKey = "F12"
  Case vbKeyHome: StrKey = "Home"
  Case vbKeyEnd: StrKey = "End"
  Case vbKeyPageUp: StrKey = "PageUp"
  Case vbKeyPageDown: StrKey = "PageDown"
End Select
TextBox1.Text = strMask & StrKey
End Sub
The KeyCode Select Case statement above contains only a partial KeyCode listing - see the VBA help file for the full KeyCode listing.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
key bindings



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show Key Combination Pressed by User Autofill form in word in combination with VBA nouki Word VBA 9 10-14-2015 01:20 PM
Show Key Combination Pressed by User Preventing text from moving down in a form when enter is pressed tgeary00 Word 2 10-29-2013 06:51 PM
Show Key Combination Pressed by User tcp-t F3 key combination used in template revans611 Word 1 11-29-2010 11:57 AM
Help with Combination function sanasath Excel 0 12-13-2005 07:24 AM
Outlook problem - Open Other User’s Folder doesn’t show Sent imported_bankboysb Outlook 0 12-12-2005 11:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft