Detecting Space-down on a mouse click

Discussion in 'Java' started by Aaron Fude, Sep 18, 2004.

  1. Aaron Fude

    Aaron Fude Guest

    Hi,

    The modifiers of the mouse-clicked event object tell me weather alt or shift
    or ctrl key is down. What's the best way to detect whether some other key
    (such as "Space" or "a") is down? The idea is to simulate the photoshop
    feature that when alt and space are both pressed the active tool switches to
    zoom.

    I have a solution in mind where the overall frame captures the clicks and
    stores it in some kind of global object, etc. But that seems overly
    complicated for this simple task. Besides, I can't always control the JFrame
    that my component will end up in.

    Very many thanks in advance!

    Aaron Fude
    Aaron Fude, Sep 18, 2004
    #1
    1. Advertising

  2. Aaron Fude

    Paul Lutus Guest

    Aaron Fude wrote:

    > Hi,
    >
    > The modifiers of the mouse-clicked event object tell me weather alt or
    > shift or ctrl key is down. What's the best way to detect whether some
    > other key (such as "Space" or "a") is down?


    There is an important distinction you need to make between alt/shift/ctrl
    and space. The former are modifiers for keystrokes, the latter is a
    keystroke event.

    Because the latter is an event, and in reading your plan, I would say you do
    not want to try to use it as you are doing.

    > The idea is to simulate the
    > photoshop feature that when alt and space are both pressed the active tool
    > switches to zoom.


    So? Detect the same combination that Photoshop detects. Surely you don't
    think the patent police will come after you for using the same keystroke
    combination for your own purposes, do you?

    >
    > I have a solution in mind where the overall frame captures the clicks and
    > stores it in some kind of global object, etc. But that seems overly
    > complicated for this simple task. Besides, I can't always control the
    > JFrame that my component will end up in.


    Okay, fine. But you are much better off using a passive modifier like
    alt/shift or some similar choice.

    --
    Paul Lutus
    http://www.arachnoid.com
    Paul Lutus, Sep 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davisro
    Replies:
    2
    Views:
    1,289
    Jim Corey
    Apr 23, 2004
  2. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,865
    Bryan Bullard
    Jul 11, 2003
  3. Christian Seberino
    Replies:
    21
    Views:
    1,623
    Stephen Horne
    Oct 27, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    979
    Steve Lamb
    Oct 23, 2003
  5. Daniish
    Replies:
    2
    Views:
    231
    Thomas 'PointedEars' Lahn
    Jun 13, 2008
Loading...

Share This Page