Silverfrost Forums

Welcome to our forums

Keyboard monitoring

10 Mar 2014 6:27 #13826

G'day, folks 😄

I seek an example of using -

subroutine add_keyboard_monitor@( cb_func )
external cb_func
  • to collect anything typed at the keyboard. In particular I seek example(s) of the 'anatomy' of the call-back function 'cb_func'

My manual states that keyboard call-back functions use clearwin_info@ parameter 'keyboard_key' but the list of parameters in my manual does not include 'keyboard_key'. My manual lists -

intermediate_scroll latest_formatted_window

No mention of keyboard_key

Eric, in Perth, Western Australia

10 Mar 2014 7:16 #13827

I used something like the following piece of code for a Tetris game:

   integer function kbd_monitor()
     integer :: key

     key = CLEARWIN_INFO@('KEYBOARD_KEY')
     if (key.eq.Z'148') up    = .true.
     if (key.eq.Z'150') down  = .true.
     if (key.eq.Z'14B') left  = .true.
     if (key.eq.Z'14D') right = .true.
     if (key.eq.Z'20') space = .true.

     kbd_monitor=2
   end function kbd_monitor

Then inside the game loop I tested if a key was set to .true. , handled a key press and reseted the key state to .false.

11 Mar 2014 2:35 #13828

Quoted from jalih

       key = CLEARWIN_INFO@('KEYBOARD_KEY')

Then inside the game loop I tested if a key was set to .true. , handled a key press and reseted the key state to .false.

Thankyou so much, jalih 😄 Your help is warmly appreciated. The assignment to 'key' is the missing link I was searching for.

Eric - enthused 😄

Please login to reply.