keyread.e:

new topic     » topic index » view thread      » older message » newer message

Hi,

Hawke referred me to "keyread.e" to be able to see when a key is released,
so I'm trying to see how to use it; the author says to use his
"clear_keys()" procedure if you use the regular "get_key()" in addition to
his "get_keys()", which I do, so I did, but it crashes *with* the "clear"
procedure and doesn't without.

Has anyone used this "get_keys()" function before who might know what's
going on?  I don't want to invite random crashes into my program if it needs
the "clear" like he says, but it seems to *make* crashes instead of fix
them.

(I did try putting the "clear" after the author's function "get_keys()"
instead of after "get_key()", but that crashed too, after press key 3
times.)

Dan Moyer

< demo program of problem after following>


<keyread.e author says:>
--
-- Everyone using my keyread.e include file should now replace it with this
-- updated version. A bug has been fixed that could cause it to crash
-- (in programs that use it along with the ordinary input routines).
-- It has a new procedure, clear_keys(), that should be called after any
-- calls to these normal routines, i.e. get_key(), gets(0), etc., but it
-- is not necessary if your program uses only get_keys().
--
-- Regards,
--             Michael Bolin
--             February 4, 1998

<code example begins>

-- ORIGINALLY:
-- find out what numeric key code is generated by any key on the keyboard
-- usage:
--          ex key

--NOW:
-- test usage of keyread.e

include keyread.e

integer code
sequence someKeys

puts(1, "Press any key. I'll show you the key code. Press q to quit\n\n")
while 1 do
    code = get_key()
--  clear_keys()  -- if left in, this crashes after a few keypresses, even
though
--   --it is "supposed" to be there to *prevent* crashes
    if code != -1 then
       printf(1, "The key code is: %d\n", code)
       if code = 'q' then
         exit
      end if
    end if

    someKeys = get_keys()
    if length(someKeys) != 0 then
        print(1, someKeys)
        if code = 'q' then
           exit
        end if
    end if

end while

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu