keyCode

概要

p5.jsリファレンス(参考情報)

[p5.js] keyCode

サンプル

def setup
  background(220)
  @fillVal = 126
end

def draw
  fill(@fillVal)
  rect(25, 25, 50, 50)
end

def keyPressed
  if keyCode == UP_ARROW
    @fillVal = 255
  elsif keyCode == DOWN_ARROW
    @fillVal = 0
  end
end
def setup
  background('yellow')
end

def keyPressed
  background('yellow')
  text("#{key} #{keyCode}", 10, 40)
end

構文

戻値