inputs

raw JSON →
0.5 verified Mon Apr 27 auth: no python

Cross-platform Python library for reading input events from keyboards, mice, and gamepads. Version 0.5 provides a consistent API across Windows, Linux, and macOS via raw device access. Release cadence is low; last updated 2020.

pip install inputs
error AttributeError: module 'inputs' has no attribute 'get_gamepad'
cause Older version of inputs or misspelled function name.
fix
Use 'from inputs import get_gamepad' (note: 'gamepad' not 'gamepad'). Check pip show inputs version >= 0.4.
error PermissionError: [Errno 13] Permission denied: '/dev/input/event0'
cause User lacks read permissions on input device files on Linux.
fix
Run script with sudo or add user to 'input' group: sudo usermod -aG input $USER and re-login.
error OSError: [Errno 19] No such device
cause No input device found (e.g., gamepad not connected or driver not loaded).
fix
Ensure the device is connected and recognized (ls /dev/input/ on Linux). On Windows, install drivers if needed.
gotcha On Linux, event devices (e.g., /dev/input/event*) require read permissions. Run with sudo or add user to the 'input' group.
fix sudo usermod -aG input $USER && log out and back in
gotcha The library does not support blocking reads; events are only returned when devices have been polled. Continuous polling may cause high CPU usage.
fix Add a small sleep inside the loop, e.g., time.sleep(0.1)
deprecated The 'inputs' library is no longer actively maintained. Consider using 'pynput' or 'evdev' directly for future development.
fix Migrate to pynput (pip install pynput) for cross-platform input control.
breaking macOS support requires additional permissions and may not work without granting accessibility access to the terminal/IDE.
fix Go to System Preferences > Security & Privacy > Privacy > Accessibility and add your terminal app.

Poll gamepad events in a loop. On Linux, ensure user has read permissions on /dev/input/event*.

from inputs import get_gamepad

def main():
    while True:
        events = get_gamepad()
        for event in events:
            print(event.ev_type, event.code, event.state)

if __name__ == "__main__":
    main()