Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SET KEYCOMP, Set(“KeyComp”)

“KeyComp” is short for Keyboard Compatibility. This command lets you decide whether to make the keyboard work more or less as it does in FoxPro/DOS or adhere to Windows standards. These days, we generally choose the latter, except in very special circumstances.

Usage

SET KEYCOMP TO DOS | WINDOWS | MAC
cKeyComp = SET( "KEYCOMP" )

Let’s start with the easy one. SET KEYCOMP TO MAC is ignored in Visual FoxPro for Windows. There’s no easy way to make a Windows app behave like a Mac app (not to mention that our Windows users would have a terrible time with our apps if we could).

The differences between the other two settings break into a few categories. The most important are default buttons and hotkeys.

One of the changes DOS users find most difficult to adapt to when they start working in Windows is the behavior of default buttons. Before the Windows standards came along, you pressed Enter to move from field to field in a form. In Windows, Enter chooses the default button. (Be aware that any button that has focus becomes the default button. When focus moves to an object other than a button, the button whose Default property is .T. once again becomes the default. In other words, when a button has focus, pressing Enter chooses that button, no matter which button is designated as the default.) If you SET KEYCOMP TO DOS, Enter doesn’t do that anymore—you have to use CTRL+Enter.

In FoxPro/DOS, hotkeys on buttons and check boxes are only available when the focus is on that kind of object. When focus is in a text box or edit box or listbox (actually, their 2.x equivalents, of course), hotkeys aren’t available. SETting KEYCOMP TO DOS lets Visual FoxPro behave the same way. In addition, with that setting, ALT+hotkey doesn’t do anything.

Somehow, the setting of KEYCOMP seemed much more important in FoxPro 2.x. Maybe that’s because there was a DOS version we needed to maintain compatibility with. The farther we get from that version, the more strongly we feel that this is a command to forget.

Example

SET KEYCOMP TO DOS

See Also

Caption, Default