Check if any key is pressed

What is a good way to check if the player presses any key?


Currently refactoring this script (event trigger labels) and every frame, it is checking a bunch of things unnecessarily for any action trigger events.


Ideally, I should only be checking for event triggering if the player actually pushed a button, so I would like to put in a conditional branch that checks whether any key is pressed before continuing with more checks.
This SOUNDS as if it might be useful, but I can't get it to work. I don't know much about calls to Windows API functions other than those I've already seen used elsewhere (as in, getting the format/syntax right for Ruby).
Any key, as some projects could be using full keyboard or other input-related scripts.

As long as I'm not checking every frame, but am not missing any potential key presses.

Here's some code for that function based on cidiomar's Full Keyboard Input

Code:
module Input    GetKeyboardState  = Win32API.new("user32.dll", "GetKeyboardState",  "I", "I")  DOWN_STATE_MASK   = (0x8 << 0x04)    def self.any_key_pressed?    0.upto(255).each do |key|      return true if (@state[key] & DOWN_STATE_MASK) == DOWN_STATE_MASK    end    return false  end    class << self    attr_reader :triggered, :pressed, :released, :repeated, :state    alias :th_input_check_update :update  end    def self.update        GetKeyboardState.call(@state.to_i)    p any_key_pressed?    th_input_check_update  endend
However it is constantly true for me even though I'm not pressing anything, so maybe I'm not checking something properly.

Original thread: https://forums.rpgmakerweb.com/threads/check-if-any-key-is-pressed.18492/