keyboard

v0.1.7
keyIsDown(k);

Check if a keyboard key is pressed, returns true if key is down and returns false if it's not

Arguments

kThe keyboard key to check as a key global, or a string

Returns

booleanWhether or not the key is down

-- Use a string 
if (keyIsDown('a')) then
  -- key 'a' is down
end

-- use a global
if (keyIsDown(LEFT_ARROW)) then
  -- left arrow is down
end
See keyIsDown in keyboard.h
keyPressed(key, keyCode);Event

Called whenever a key is pressed.

Arguments

keyThe pressed key as a string, is nil if glfw cannot find a name for the key.
keyCodeThe pressed key as a key code

function setup()
   createWindow(200, 200);

   background('purple');
   text('Press any key', 10, 40);
end

-- no draw
function draw() return end 

function keyPressed(key, keyCode)
   print(key, keyCode);

   background('purple');

   if key ~= nil then 
       text('Pressed: ' .. key, 10, 40);
   end
end

Output

See keyPressed in keyboard.h
keyReleased(key, keyCode);Event

Called whenever a key is released.

Arguments

keyThe released key as a string, is nil if glfw cannot find a name for the key
keyCodeThe released key as a key code

function setup()
   createWindow(200, 200);

   background('purple');
   text('Release any key', 10, 40);
end

-- no draw
function draw() return end 

function keyReleased(key, keyCode)
   print(key, keyCode);

   background('purple');

   if key ~= nil then 
       text('Released: ' .. key, 10, 40);
   end
end

Output

See keyReleased in keyboard.h
keyHeld(key, keyCode);Event

Called whenever a key is held down.

Arguments

keyThe held key as a string, is nil if glfw cannot find a name for the key
keyCodeThe held key as a key code

function setup()
   createWindow(200, 200);

   background('purple');
   text('Hold any key', 10, 40);
end

-- no draw
function draw() return end 

function keyHeld(key, keyCode)
   print(key, keyCode);

   background('purple');

   if key ~= nil then 
       text('Held key: ' .. key, 10, 40);
   end
end

Output

See keyHeld in keyboard.h
UP_ARROWConstant

No description

See UP_ARROW in keyboard.h
DOWN_ARROWConstant

No description

See DOWN_ARROW in keyboard.h
LEFT_ARROWConstant

No description

See LEFT_ARROW in keyboard.h
RIGHT_ARROWConstant

No description

See RIGHT_ARROW in keyboard.h
KEY_ENTERConstant

No description

See KEY_ENTER in keyboard.h
KEY_BACKSPACEConstant

No description

See KEY_BACKSPACE in keyboard.h
KEY_AConstant

No description

See KEY_A in keyboard.h
KEY_BConstant

No description

See KEY_B in keyboard.h
KEY_CConstant

No description

See KEY_C in keyboard.h
KEY_DConstant

No description

See KEY_D in keyboard.h
KEY_EConstant

No description

See KEY_E in keyboard.h
KEY_FConstant

No description

See KEY_F in keyboard.h
KEY_GConstant

No description

See KEY_G in keyboard.h
KEY_HConstant

No description

See KEY_H in keyboard.h
KEY_IConstant

No description

See KEY_I in keyboard.h
KEY_JConstant

No description

See KEY_J in keyboard.h
KEY_KConstant

No description

See KEY_K in keyboard.h
KEY_LConstant

No description

See KEY_L in keyboard.h
KEY_MConstant

No description

See KEY_M in keyboard.h
KEY_NConstant

No description

See KEY_N in keyboard.h
KEY_OConstant

No description

See KEY_O in keyboard.h
KEY_PConstant

No description

See KEY_P in keyboard.h
KEY_QConstant

No description

See KEY_Q in keyboard.h
KEY_RConstant

No description

See KEY_R in keyboard.h
KEY_SConstant

No description

See KEY_S in keyboard.h
KEY_TConstant

No description

See KEY_T in keyboard.h
KEY_UConstant

No description

See KEY_U in keyboard.h
KEY_VConstant

No description

See KEY_V in keyboard.h
KEY_WConstant

No description

See KEY_W in keyboard.h
KEY_XConstant

No description

See KEY_X in keyboard.h
KEY_YConstant

No description

See KEY_Y in keyboard.h
KEY_ZConstant

No description

See KEY_Z in keyboard.h