Command-key presses 
Author Message
 Command-key presses

Is there a way in RealBasic to have a command key shortcut not associated
with a menu item?

I want cmd-Q and cmd-W to quit the program. The Q shortcut is associtated
with the Quit menu item (and works), but i don't want to add Close menu item
for the W shortcut. And the window's "KeyDown" function doens't seem to get
keys when the cmd key is down...

But i don't want to use a Timer to check all the time if the keys are
pressed...

Thanks a lot!

--- Chris Comeau ---

"Friends don't let friends do DOS."



Sun, 09 Jun 2002 03:00:00 GMT  
 Command-key presses

Quote:

> Is there a way in RealBasic to have a command key shortcut not associated
> with a menu item?

You have to check for keyboard.commandkey or keyboard.asynccommandkey

Quote:
> I want cmd-Q and cmd-W to quit the program. The Q shortcut is associtated
> with the Quit menu item (and works), but i don't want to add Close menu item
> for the W shortcut.

Why not? How is the user supposed to know that cmd-W does anything then?
Add the menu item.

/sam



Sun, 09 Jun 2002 03:00:00 GMT  
 Command-key presses

Quote:

> I want cmd-Q and cmd-W to quit the program. The Q shortcut is associtated
> with the Quit menu item (and works), but i don't want to add Close menu item
> for the W shortcut. And the window's "KeyDown" function doens't seem to get
> keys when the cmd key is down...

> But i don't want to use a Timer to check all the time if the keys are
> pressed...

When the command key is held down, the EnableMenuItems event fires, so you
can check for AsyncKeyDown(whatever) in the EnableMenuItems event, and
handle it from there.

Much better than AsyncKeyDown() is Rolf Heller's CharKeyCode XFCN (search
for it at any XCMD site). That1s because Heller's XFCN "knows" where the
keys have been mapped -- but if you use keycodes, the code for "W" on your
machine may be a different character on an international, Dvorak, etc.
keyboard.

-- Steve

--
-------------------------------------------------------


-------------------------------------------------------



Mon, 10 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to capture key-presses (keyboard-presses)???

2. IBM VA close window upon key pressed event

3. Tracking key presses, mouse clicks and mouse movements?

4. many keys pressed at the same time

5. Changing the cursor when control key pressed.

6. Key press events on a window

7. Selecting TAB sheet by pressing TAB key

8. Keycode() - Getting a response to a key press

9. Trapping a key press event

10. pressing ESC key in source procedure

11. KEY PRESSED DETECT(@@@@ Help Please @@@@)

12. How to find when the enter key pressed in a memo

 

 
Powered by phpBB® Forum Software