script

apple script

  • sample code:

    tell application "System Events"
      key code 124 using {shift down, command down} --> Right arrow
      key code 8 using command down --> ⌘-C
      key code {4, 14, 37, 37, 31, 47} --> H, e, l, l, o, .
    
      keystroke "v" using command down --> ⌘-V
      keystroke "Hello." --> H, e, l, l, o, .
    end tell

key code

[!NOTE|label:references:]

KEY
KEY CODE
KEY
KEY CODE
KEY
KEY CODE

!1

18

"'

39

I

34

@2

19

_-

27

O

31

#3

20

+=

24

P

35

$4

21

<,

43

K

40

%5

23

>.

47

L

37

^6

22

?/

44

Z

6

&7

26

N

45

X

7

*8

28

M

46

C

8

(9

25

Q

12

V

9

)0

29

W

13

B

11

~`

50

E

14

A

0

{[

33

R

15

S

1

}]

30

T

17

D

2

|</code>

42

Y

16

F

3

:;

41

U

32

G

5

H

4

J

38

function keys

KEY
KEY CODE
KEY
KEY CODE
KEY
KEY CODE

␣ space

49

β‡₯ tab

48

⌫ delete

51

⏎ return

36

⌦ forwarddelete

117

␊ linefeed

52

βŽ‹ esc

53

⌘ command

55

⇧ shift

56

β‡ͺ capslock

57

βŒ₯ option

58

βŒƒ control

59

⇧ right shift

60

βŒ₯ right option

61

βŒƒ right control

62

⇱ home

115

⇲ end

119

β‡ž page up

116

β‡Ÿ page down

121

← left arrow

123

β†’ right arrow

124

↓ down arrow

125

↑ up arrow

126

-

-

Fn keys

KEY
KEY CODE
KEY
KEY CODE
KEY
KEY CODE

F1

122

F2

120

F3

99

F4

118

F5

96

F6

97

F7

98

F8

100

F9

101

F10

109

F11

103

F12

111

Number pad

KEY
KEY CODE
KEY
KEY CODE
KEY
KEY CODE

1

83

2

84

3

85

4

86

5

87

6

88

7

89

8

91

9

92

0

82

*

67

/

75

+

69

-

78

=

81

.

65

clear

71

-

-

Last updated

Was this helpful?