[comp.sys.sgi] changing key bindings

james@smectos.gang.umass.edu (Jim Riordan) (04/10/90)

Does anybody know how to rebind the keys on an SGI 4D240 running NeWS
so that the <caps lock> key acts as <ctrl>? Please reply by email.

thanks in advance,
James Riordan
james@smectos.gang.umass.edu

rab@alice.UUCP (Rick Becker) (04/13/90)

In article <12704@dime.cs.umass.edu>, james@smectos.gang.umass.edu (Jim Riordan) writes:
> Does anybody know how to rebind the keys on an SGI 4D240 running NeWS
> so that the <caps lock> key acts as <ctrl>? 

Your question about interchanging the control and caps lock keys was
addressed some time ago in this newsgroup.  Here's a summary.

We decided to make the change affect all users on our machines, and
not be something that required individuals to modify their own setup
code.  We also wanted to take it one step further, by interchanging the
keycaps -- a bit of surgery with a sharp knife can make the wide
control key cap fit into the space vacated by caps lock.

To change the software, we added one line to /usr/NeWS/lib/NeWS/init.ps:

(NeWS/keyflip.ps) LoadFile pop

just before the LoadFile for startup.ps.  

Here is the definition for the file /usr/NeWS/lib/NeWS/keyflip.ps.
Most of this was copied from something on netnews 
(I forget the original source).


% Code to change key bindings.
% The call to replacekeys swaps the Ctrl and Caps Lock keys,
% as well as the Esc and ~/` keys.

/replacekeys { % origkeyvals_array changedkeyvals_array -> -
        {
                /changedvals exch def
                /origvals exch def
                /keysdict origvals length dict def
                keysdict begin
                        0 1 origvals length 1 sub {
                                dup origvals exch get changedvals
                                3 2 roll get def
                        } for
                end
                createevent dup begin
                        /Name origvals def
                        /Priority 2 def
                        /Exclusivity true def
                end
                expressinterest
                {
                        awaitevent dup dup begin
                        /Name get keysdict exch get /Name exch def
                        end
                        redistributeevent
                } loop
        } fork pop pop pop
} def
[ 28420 28419 28471 28423 ] [ 28419 28420 28423 28471 ] replacekeys

%28423	Escape
%28420	Caps Lock
%28419	Ctrl (left side)
%28471	` and ~


The line calling replacekeys interchanges the meanings of caps lock
and the left-side control key and also interchanges escape with the `~
key (useful with vi).

Hope this helps -- we really like the changed keyboard.
-- 

    Rick Becker  alice!rab  rab@research.att.com