Computer Learning Zone CLZ Access Excel Word Windows

What sculpture is to a block of marble, education is to the human soul.

-Joseph Addison
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Code Vault > Access VBA > GetKeyState
Get Key State - Free
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   3 years ago

Get the current state of the CapsLock, NumLock, or ScrollLock keys

Option Compare Database
Option Explicit

' Disclaimer: I haven't tested this on 64-bit yet. Let me know if you have problems

#If VBA7 Then
    Public Declare PtrSafe Function GetKeyState Lib "user32" (ByVal myKey As Long) As Integer
#Else
    Public Declare Function GetKeyState Lib "user32" (ByVal myKey As Long) As Integer
#End If

Private Const KeyNumLock = &H90
Private Const KeyCapsLock = &H14
Private Const KeyScrollLock = &H91

Function GetCapsLock() As Boolean
    GetCapsLock = CBool(GetKeyState(KeyCapsLock) And 1)
End Function

Function GetNumLock() As Boolean
    GetNumLock = CBool(GetKeyState(KeyNumLock) And 1)
End Function

Public Function GetScrollLock() As Boolean
    GetScrollLock = CBool(GetKeyState(KeyScrollLock) And 1)
End Function

 

Usage:

If GetCapsLock()=TRUE then DoSomeStuff

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Get Key State - Free
Get notifications when this page is updated
 
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/28/2024 10:23:51 AM. PLT: 1s
Keywords: code vault access getkeystate get key state capslock numlock scrolllock caps lock num lock scroll lock  PermaLink  Get Key State - Free