home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / TESTKEYS.E < prev    next >
Text File  |  1992-08-26  |  2KB  |  55 lines

  1. ; A blank keyset which lets you see what the internal values for keys are.
  2. ; Note that if EPM control 26 is on, then arrows are handled internally,
  3. ; and won't be seen by this routine.  TOGGLECONTROL 26 0 to turn that off.
  4.  
  5. ; By Larry Margolis
  6.  
  7. defc testkeys
  8.    universal TEST_STARTING_KEYSET
  9.    if .keyset = 'TEST_KEYS' then
  10.       sayerror 'Already in testkeys mode.  Command ignored.'
  11.       return
  12.    endif
  13.    TEST_starting_keyset = upcase(.keyset)
  14.    keys testkeys
  15.    sayerror 'Press Esc or End key twice to exit.'
  16.  
  17. defkeys testkeys new clear
  18.  
  19. def otherkeys =
  20.    universal TEST_STARTING_KEYSET
  21.    k = lastkey()
  22.    msg = ''
  23.    if length(k)=1 then
  24.       ch = 'chr('asc(k)')'
  25.    else
  26.       ch = "x'"rightstr(itoa(leftstr(k,1)\0,16),2,0) || rightstr(itoa(substr(k,2,1)\0,16),2,0)"'"
  27.       if k=space then
  28.          ch = ch '(Space)'
  29.       elseif k=s_space then
  30.          ch = ch '(Shift+Space)'
  31.       elseif k = \10\18 then
  32.          ch = ch '(Ctrl)'
  33.       elseif k = \09\10 then
  34.          ch = ch '(Shift)'
  35.       elseif k = \11\34 then
  36.          ch = ch '(Alt)'
  37.       endif
  38.       if k=\x13\x02 | k=\x0f\x02 then    -- Esc or End
  39.          if lastkey(1) = k then
  40.             .keyset = TEST_STARTING_KEYSET
  41.             call beep(900,100)
  42.             sayerror 'Back to keyset' .keyset
  43.             return
  44.          endif
  45.          msg = 'Press again to exit testkeys.'
  46.       endif
  47.    endif
  48. compile if 1         -- 1 if you want to
  49.    keys edit_keys    -- switch to the starting keyset,
  50.    executekey k      -- execute the pressed key,
  51.    keys testkeys     -- then switch back.
  52. compile endif
  53.    sayerror 'key =' ch '= "'k'"' msg
  54.  
  55.