Javascript key codes

keycode(key = NULL, code = NULL)



character vector specifying keynames (default = NULL)


numeric vector specfiying keycodes (default = NULL)


A numeric or character vector


This function provides a mapping between the human-readable javascript key names and their corresponding numeric code values. If both input arguments are NULL, it returns a named numeric vector whose values correspond to the key codes and whose names correspond to the key names. If key is specified the return value is a vector with the corresponding numeric codes; whereas if code is specified the output is a character vector containing the corresponding key names. If neither argument is NULL the function throws an error.