キーの長押しの検出状態の取得

love.keyboard.hasKeyRepeat

追加バージョン0.9.0削除バージョン-

キーの長押しの有効・無効を取得します。

local text = ""

function love.draw()
  love.graphics.print(tostring(love.keyboard.hasKeyRepeat()), 20, 20)
  love.graphics.print(text, 20, 40)
end

function love.keypressed(key)
  if key == "t" then
    love.keyboard.setKeyRepeat(true)
    text = ""
  elseif key == "f" then
    love.keyboard.setKeyRepeat(false)
    text = ""
  else
    text = text .. key
  end
end
キーの長押しの検出状態の取得

キーボードの「t」「f」を押すとキーの長押し有効状態がtrueまたはfalseで表示されます。