Next / Previous / Contents

54.5. Key names

The detail part of an event pattern for a KeyPress or KeyRelease event specifies which key you're binding. (See the Any modifier, above, if you want to get all keypresses or key releases).

The table below shows several different ways to name keys. See Section 54.6, “Writing your handler: The Event class”, below, for more information on Event objects, whose attributes will describe keys in these same ways.

There are many more key names for international character sets. This table shows only the “Latin-1” set for the usual USA-type 101-key keyboard. For the currently supported set, see the manual page for Tk keysym values.

.keysym.keycode.keysym_numKey
Alt_L6465513The left-hand alt key
Alt_R11365514The right-hand alt key
BackSpace2265288backspace
Cancel11065387break
Caps_Lock6665549CapsLock
Control_L3765507The left-hand control key
Control_R10965508The right-hand control key
Delete10765535Delete
Down10465364
End10365367end
Escape965307esc
Execute11165378SysReq
F16765470Function key F1
F26865471Function key F2
Fi66+i65469+iFunction key Fi
F129665481Function key F12
Home9765360home
Insert10665379insert
Left10065361
Linefeed54106Linefeed (control-J)
KP_090654380 on the keypad
KP_187654361 on the keypad
KP_288654332 on the keypad
KP_389654353 on the keypad
KP_483654304 on the keypad
KP_584654375 on the keypad
KP_685654326 on the keypad
KP_779654297 on the keypad
KP_880654318 on the keypad
KP_981654349 on the keypad
KP_Add8665451+ on the keypad
KP_Begin8465437The center key (same key as 5) on the keypad
KP_Decimal9165439Decimal (.) on the keypad
KP_Delete9165439delete on the keypad
KP_Divide11265455/ on the keypad
KP_Down8865433↓ on the keypad
KP_End8765436end on the keypad
KP_Enter10865421enter on the keypad
KP_Home7965429home on the keypad
KP_Insert9065438insert on the keypad
KP_Left8365430← on the keypad
KP_Multiply6365450× on the keypad
KP_Next8965435PageDown on the keypad
KP_Prior8165434PageUp on the keypad
KP_Right8565432→ on the keypad
KP_Subtract8265453- on the keypad
KP_Up8065431↑ on the keypad
Next10565366PageDown
Num_Lock7765407NumLock
Pause11065299pause
Print11165377PrintScrn
Prior9965365PageUp
Return3665293The enter key (control-M). The name Enter refers to a mouse-related event, not a keypress; see Section 54, “Events”
Right10265363
Scroll_Lock7865300ScrollLock
Shift_L5065505The left-hand shift key
Shift_R6265506The right-hand shift key
Tab2365289The tab key
Up9865362