Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #1737

Re: Defining action of CTRL key...

Date 2012-05-24 22:51 +0100
From Matthew Phillips <spam2011m@yahoo.co.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: Defining action of CTRL key...
Message-ID <4228159552.Matthew@sinenomine.freeserve.co.uk> (permalink)
References (3 earlier) <396e079452.martin@bach.planiverse.com> <7e0d1b1e-8a6b-442d-bf39-1804a80ac511@3g2000vbx.googlegroups.com> <1f7f4803-c3ca-4c50-b063-d07b7f61a0f3@b1g2000vbb.googlegroups.com> <47c33578-ba43-4f5e-9e25-39dd0527a9ca@m10g2000vbn.googlegroups.com> <f85b54c4-eccd-4b57-9a8e-6bdd30435c9b@w24g2000vby.googlegroups.com>

Show all headers | View raw


In message <f85b54c4-eccd-4b57-9a8e-6bdd30435c9b@w24g2000vby.googlegroups.com>
 on 24 May 2012 jgharston  wrote:

> Gazza wrote:
> > Any help or advice would be appreciated here.
> 
>       REPEAT
>         K%=GET:S%=INKEY-1:C%=INKEY-2
>         IF S%:PRINT" Shift:";
>         IF C%:PRINT" Ctrl:";
>         IF K%<32 OR K%=127 PRINT "^";CHR$(K% EOR 64); ELSE PRINT CHR$K
> %;
>       UNTIL FALSE

That will work nicely if the processing you do on the key presses is swift. 
If a keypress results in some long-winded processing, the user can press
further keys which will be buffered (remembered).  While the character that
the key would generate is remembered and buffered properly, the above code is
reading the state of the shift and ctrl keys *now*, not what they were when
the character you have just read with GET was actually generated by the
keyboard.

If the user changes the state of the shift or ctrl key while your program is
caught up in some heavy task and is not responding, then when it catches up
with the buffered input you might end up thinking the user pressed the "a"
key at the same time as shift, when actually the "a" had been buffered and
the shift key was pressed later.

If all that could cause a problem you have various options.  One is to run
through all the keys using negative INKEY values and read the keyboard state
as it is at that instant.  You can then detect any combination of keys the
ham-fisted user might be pressing all at once.  But it's not a good method
for handling ordinary typing, as you would have to deal with keyboard
auto-repeat and all that malarky yourself.

The other option is something like the DeepKeys module, which I think only
applies with the Wimp's key pressed messages.  That manages (I think) to
store the state of various modifier keys as they were at the time of the
actual keypress.

-- 
Matthew Phillips
Durham

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-22 08:42 -0700
  Re: Defining action of CTRL key... Martin Wuerthner <spamtrap@mw-software.com> - 2012-05-22 18:09 +0200
    Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-22 11:33 -0700
      Re: Defining action of CTRL key... Martin Wuerthner <spamtrap@mw-software.com> - 2012-05-22 22:45 +0200
        Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-22 16:03 -0700
          Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-22 23:42 -0700
            Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-23 16:20 -0700
              Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-24 13:59 -0700
                Re: Defining action of CTRL key... Matthew Phillips <spam2011m@yahoo.co.uk> - 2012-05-24 22:51 +0100
                Re: Defining action of CTRL key... Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2012-05-26 16:16 +0200
              Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-25 07:04 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-25 07:48 -0700
                Re: Defining action of CTRL key... Steve Drain <steve@kappa.me.uk> - 2012-05-25 16:30 +0100
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-27 05:43 -0700
                Re: Defining action of CTRL key... Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2012-05-26 16:08 +0200
                Re: Defining action of CTRL key... Harriet Bazley <bazley@feathermail.co.uk> - 2012-06-08 08:55 +0100
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-08 01:16 -0700
            Re: Defining action of CTRL key... Martin Wuerthner <spamtrap@mw-software.com> - 2012-05-24 11:07 +0200
              Re: Defining action of CTRL key... Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2012-05-26 16:18 +0200
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-27 02:25 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-27 10:00 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-27 10:55 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-29 10:30 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-29 14:14 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-29 16:32 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-29 17:34 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-30 04:06 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-05-30 04:35 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-30 05:40 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-30 10:26 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-05-31 06:56 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-01 05:02 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-01 07:01 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-01 07:54 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-06-02 18:18 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-03 01:02 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-06-06 17:29 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-07 16:37 -0700
                Re: Defining action of CTRL key... Steve Drain <steve@kappa.me.uk> - 2012-06-08 12:00 +0100
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-08 09:00 -0700
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-11 16:14 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-06-17 17:12 -0700
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-06-18 13:24 -0700
                Re: Defining action of CTRL key... Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2012-06-16 20:18 +0100
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-17 16:08 -0700
                Re: Defining action of CTRL key... Jeremy Nicoll - news posts <jn.nntp.scrap007@wingsandbeaks.org.uk> - 2012-06-18 04:45 +0100
                Re: Defining action of CTRL key... Gazza <usenet@garethlock.com> - 2012-06-18 14:49 -0700
                Re: Defining action of CTRL key... druck <news@druck.org.uk> - 2012-06-18 18:41 +0100
                Re: Defining action of CTRL key... jgharston <jgh@arcade.demon.co.uk> - 2012-06-18 13:26 -0700

csiph-web