Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 20 in printed book and digital formats -- plus a one-year subscription (beginning with 21.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Recent issues

Article Preview

Buy Now

Issue 3.6


Get a Handle on Your Keyboard

How to take charge of your keyboard using the Windows API and REALbasic

Issue: 3.6 (July/August 2005)
Author: Hank Marquis
Author Bio: Hank Marquis has been using REALbasic since the very beginning. He is the author of a number of VB books and frequently speaks at REAL Software and Apple events. He is currently CTO of SlayFire Software Co., creating optimization and performance tools for REALbasic. Reach him at hank@slayfire.com or www.slayfire.com.
Article Description: No description available.
Article Length (in bytes): 14,029
Starting Page Number: 30
Article Number: 3613
Related Link(s): None

Excerpt of article text...

REALbasic provides several means for working with the keyboard. There is the KeyDown event and the Keyboard object for use in your applications. The KeyDown event occurs when the item with focus receives a message from the operating system indicating the user pressed a keyboard key. However, REALbasic only provides an event for KeyDown (the Windows WM_KEYDOWN message). Windows also has WM_KEYUP, WM_SYSKEYDOWN, and WM_SYSKEYUP messages, among others.

Using the Keyboard object, you determine if specific keys are pressed, or have been pressed. You can detect when a user holds down or has pressed-and-released a modifier key (Shift, Control, or Alt) alone or in conjunction with another key. However, there are often a number of things you need to accomplish that the stock Keyboard object does not provide. Some examples include setting Num Lock, Caps Lock, or Scroll Lock, or determining how many function keys a keyboard has.

For these and other keyboard manipulations, you will need to delve into the murky waters of the Windows API. Using the Windows API you can determine if the Caps Lock key is "On" or you can turn Num Lock "Off". REALbasic lacks a built-in method for setting keyboard key states. However, using the Windows API you can not only query the keyboard for any key's state, but you can also change or set any key's state.

Through the Windows API you can find out the keyboard's physical layout: number of function keys, layout, manufacturer, etc. You can also discover which Shift, Alt, or Control key is down (if any) -- left or right.

...End of Excerpt. Please purchase the magazine to read the full article.