Special

Clearance Sale!

We've been publishing for over five years now and it's time to clear out our inventory of back issues, so we're slashing prices!

RBD Magazines

Check out this amazing clearance sale of all our past issues. Missing some issues? This is a great time to complete your RBD collection. Save up to 40% off the regular price of our printed back issue packages. These prices are only good until the end of the year May 2008 and supplies are limited, so place your order today.

Article Preview


Buy Now

Print:
PDF:

Feature

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-at-slayfire.com or www.slayfire.com.
Article Description: No description available.
Article Length (in bytes): 12,572
Starting Page Number: 30
RBD Number: 3613
Resource File(s): None
Related Web Link(s):

www.slayfire.com

Known Limitations: 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.

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

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com