Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


SetKey

Built-in

SYNTAX

SetKey <empty> | -r | [modifierKey-]…key[-[modifierKey-]…key]
[commandString]

DESCRIPTION

The SetKey command allows you to assign keyboard equivalents for

built-in commands

script names

tool names

editor primitives

You use SetKey to bind the key sequence, which may contain an optional modifier key and a regular key, to the command string. In this way you may reconfigure the keyboard layout of the editor primitives. You may want to do this to make the MPW Shell editor perform more like a favorite line editor, such as Emacs or vi.

INPUT

None

OUTPUT

None, unless SetKey is executed without any parameters or with a key description but no command. In the first case SetKey sends a list of commands to standard output that, when executed, restores the keyboard to the current set of key assignments. If a key is specified with no command, SetKey sends the commands currently assigned to that key to standard output.

STATUS

SetKey can return the following status codes:

0

no errors

1

syntax error

2

execution error; invalid input

PARAMETERS

empty

Prints a list of commands to restore the keyboard to the current set of key assignments when there is no parameter.

[modifierKey-]…key[-[modifierKey-]…key]

Specifies the key or combination of keys to use as a keyboard equivalent. If SetKey is executed with a key description but without a command, it prints the commands currently assigned to that key. The keys you can use are shown in the following list:

clear

uparrow

;

k

f1

kp/

del

'

=

l

f2

kp+

delete

,

[

m

f3

kp-

downarrow

-

\

n

f4

kp.

end

.

]

o

f5

kp0

enter

/

`

p

f6

kp1

escape

0

a

q

f7

kp2

help

1

b

r

f8

kp3

home

2

c

s

f9

kp4

leftarrow

3

d

t

f10

kp5

pagedown

4

e

u

f11

kp6

pageup

5

f

v

f12

kp7

return

6

g

w

f13

kp8

rightarrow

7

h

x

f14

kp9

space

8

i

y

f15

kp=

tab

9

j

z

kp*

 

The optional modifier keys you can use are

command  optionshift  control

Note
The kp keys refer to the keys of the numeric keypad. Keys may also be represented by Apple's hexadecimal keycode values. They are documented in Inside Macintosh. •

commandString

Specifies the sequence of built-in commands, script names, tool names, and editor primitives that are to be bound to the key sequence. The editor primitives you can use are shown below.

DeleteCharLeft
DeleteCharRight
DeleteEndOfFile
DeleteEndOfLine
DeleteStartOfFile
DeleteStartOfLine   
DeleteWordLeft
DeleteWordRight
MoveCharLeft
MoveCharRight
MoveEndOfFile
MoveEndOfLine
MoveHalfPageDown
MoveHalfPageUp
MoveLineDown
MoveLineUp
MovePageDown
MovePageUp
MoveStartOfFile

MoveStartOfLine
MoveWordLeft
MoveWordRight
ScrollHalfPageDown
ScrollHalfPageUp
SelectCharLeft
SelectCharRight
SelectEndOfFile
SelectEndOfLine
SelectHalfPageDown
SelectHalfPageUp
SelectLineDown
SelectLineUp
SelectPageDown
SelectPageUp
SelectStartOfFile
SelectStartOfLine
SelectWordLeft
SelectWordRight

OPTIONS

-r

Reverts the key table to the default keyboard layout that was loaded from the resources in the MPW Shell.

EXAMPLES

The following command line binds the F11 key to a script that moves a window.

SetKey f11 'MoveWindow {LeftPos} "{Active}"; SizeWindow {LeftPos} "{Active}"'

Another example allows you to execute a command line using the key combination Control-X-Y.

SetKey control-x-y 'Execute `Request "Enter a Command"`'

Note that control-x-y means the sequence of pressing Control-X followed by pressing Y. In this case, Control-X is the meta-key of the sequence. Once you press Control-X, MPW is in a wait state and nothing is echoed to the active window. If you press a Y next, then the string is executed. Be sure you don't make meta-keys out of keys that are pressed often.

SEE ALSO

Editor Primitives

UnSetKey

 
 


Last Updated July 2000