[comp.windows.news] keypad.ps

don@TUMTUM.CS.UMD.EDU (Don Hopkins) (12/01/88)

Here's a handy way to moving the cursor around on the screen without
taking your hand off the keyboard. For a good time, try using keysee
to press the function keys!

	-Don

%!
% Simulate mouse movement and clicks, with shifted keypad arrows
%
% Don Hopkins, University of Maryland Human Computer Interaction Lab
%
% Copyright (C) 1988 by Don Hopkins. All rights reserved.
% This program is provided for unrestricted use, provided that this 
% copyright message is preserved. There is no warranty, and no author 
% or distributer accepts responsibility for any damage caused by this 
% program. 
%
% Fake mouse movement:
%
%   Control: small step (1 point)
%   Shift: medium step (16 points)
%   Meta: big step (100 points)
%
%     R7  R8  R9
%     R10     R12
%     R13 R14 R15
%   
% Fake mouse clicks:
%
%   Control-R11: Left mouse click
%   Shift-R11: Middle mouse click
%   Meta-R11: Right mouse click
%
% Unshifted function keys are just send through.
%

systemdict begin

% Later:
% Express interest in function key UpTransitions some how, leave
% the Action field alone, and just send one event...

/fake-button { % event name => event
  1 index createevent copy		% event name event
  begin					% event name
    /Name exch def			% event
  currentdict end			% event FakeDownEvent
  dup createevent copy			% event FakeDownEvent FakeDownEvent
  sendevent				% event FakeDownEvent
  begin					% event
    /Action /UpTransition def
  currentdict end			% event FakeUpEvent
  sendevent				% event
} def


/push-button {
  true
  1 index /KeyState get {
    { /Control { pop /LeftMouseButton fake-button false exit }
      /Shift { pop /MiddleMouseButton fake-button false exit }
      /Meta { pop /RightMouseButton fake-button false exit }
    } case
  } forall
  { redistributeevent } if
} def

/move-mouse { % event dx dy => event
  gsave
    framebuffer setcanvas
    2 index begin
      /Name /MouseDragged def
      YLocation add /YLocation exch def
      XLocation add /XLocation exch def
      XLocation YLocation setcursorlocation
    currentdict end sendevent
  grestore
} def

/mouse-small-step 1 def
/mouse-medium-step 16 def
/mouse-big-step 100 def

/push-mouse { % event x y => event
  true
  3 index /KeyState get {
    { /Control { pop
        mouse-small-step mul exch mouse-small-step mul exch
	move-mouse false exit }
      /Shift { pop
        mouse-medium-step mul exch mouse-medium-step mul exch
	move-mouse false exit }
      /Meta { pop
        mouse-big-step mul exch mouse-big-step mul exch
	move-mouse false exit }
    } case
  } forall
  { pop pop redistributeevent } if
} def

/FunctionR7 {
  -1 1 push-mouse
} bindkey

/FunctionR8 {
  0 1 push-mouse
} bindkey

/FunctionR9 {
  1 1 push-mouse
} bindkey

/FunctionR10 {
  -1 0 push-mouse
} bindkey

/FunctionR12 {
  1 0 push-mouse
} bindkey

/FunctionR13 {
  -1 -1 push-mouse
} bindkey

/FunctionR14 {
  0 -1 push-mouse
} bindkey

/FunctionR15 {
  1 -1 push-mouse
} bindkey

/FunctionR11 {
  push-button
} bindkey

end % systemdict

sjs@spectral.ctt.bellcore.com (Stan Switzer) (12/02/88)

In article <8811302318.AA00363@tumtum.cs.umd.edu> don@TUMTUM.CS.UMD.EDU (Don Hopkins) writes:
> Here's a handy way to moving the cursor around on the screen without
> taking your hand off the keyboard. For a good time, try using keysee
> to press the function keys!

Don (mad NeWS genius) strikes again!  This is fun indeed.

Note that if you use Don's PieMenus you can do almost anything from
the keyboard (menus pop up with one click and pop down with another).

Let's see...  You can type with either the keyboard or the mouse.  You
can move the mouse with the keyboard alone.  You can even type using
the keyboard to simulate the mouse simulating a keyboard....

It's too bad that you have to hold the control key down to select: you
can only type control chars in from KeySee :-(.

Stan Switzer  sjs@ctt.bellcore.com   --  Is NeWS fun OR WHAT?