Login  Register

Re: Catching keyboard with #keyPress

Posted by Blair McGlashan-3 on Oct 07, 2004; 3:21pm
URL: https://forum.world.st/Catching-keyboard-with-keyPress-tp3371732p3371741.html

"Mark Derricutt" <[hidden email]> wrote in message
news:ck291a$[hidden email]...
> I've added a handler for #keyPress:  but don't seem to see anywhere to get
> the keyboard modifiers, Ctrl and Shift seem to trigger #keyPress as keys
> in their own right, which doesn't seem correct.

That's just the way Windows transmits keyboard events.

>...What I want is to trap the user pressing ctrl+enter at the same time...

When you receive an enter key press you can check if one of the modifiers is
pressed down like this:

    Keyboard default isCtrlDown

You can check for Shift and Alt in a similar way. See the Keyboard class.

It may also be that what you really want to do is to define an
accelerator/shortcut key. This is usually done by associating a key press
with a command accessible from the menu bar, but it is also possible to
define additional accelerator combinations that are not on any menus - start
browsing from Presenter>>additionalAccelerators to understand the full
mechanism, but usually if you don't care about these being user configurable
you just need to add a #defaultAdditionalAccelerator method on the class
side of your presenter. You can browse the existing implementations of this
to see how.

Regards

Blair