keyboard.keyname(char)

Gets the key name corresponding to the provided character.

Parameters

char

A string with a single character from which the corresponding key on the keyboard will be guessed.

Notes

  • This function don't manage diacratics/accentued characters.
  • If the character is not represented by a key, this function will return a nil value.

Return value

This function returns four values if a physical key represents the specified character :
  • Astring representing the key name.
  • Aboolean value that indicates if the SHIFT should be pressed.
  • Aboolean value that indicates if the CONTROL should be pressed.
  • Aboolean value that indicates if the MENU should be pressed.

Example

local kb = require "keyboard" -- prints on french and italian keyboards : "0" false true true -- prints on other keyboards : "2" true false false print(kb.keyname("@"))