{"id":21461,"library":"inputs","title":"inputs","description":"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.","status":"active","version":"0.5","language":"python","source_language":"en","source_url":"https://github.com/zeth/inputs","tags":["input","keyboard","mouse","gamepad","cross-platform"],"install":[{"cmd":"pip install inputs","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required on Linux for reading input events","package":"evdev","optional":true}],"imports":[{"note":"Correct import path for accessing devices","wrong":null,"symbol":"DeviceManager","correct":"from inputs import DeviceManager"},{"note":"Function to read keyboard events","wrong":null,"symbol":"get_key","correct":"from inputs import get_key"},{"note":"Function to read mouse events","wrong":null,"symbol":"get_mouse","correct":"from inputs import get_mouse"},{"note":"Function to read gamepad events","wrong":null,"symbol":"get_gamepad","correct":"from inputs import get_gamepad"}],"quickstart":{"code":"from inputs import get_gamepad\n\ndef main():\n    while True:\n        events = get_gamepad()\n        for event in events:\n            print(event.ev_type, event.code, event.state)\n\nif __name__ == \"__main__\":\n    main()","lang":"python","description":"Poll gamepad events in a loop. On Linux, ensure user has read permissions on /dev/input/event*."},"warnings":[{"fix":"sudo usermod -aG input $USER && log out and back in","message":"On Linux, event devices (e.g., /dev/input/event*) require read permissions. Run with sudo or add user to the 'input' group.","severity":"gotcha","affected_versions":"all"},{"fix":"Add a small sleep inside the loop, e.g., time.sleep(0.1)","message":"The library does not support blocking reads; events are only returned when devices have been polled. Continuous polling may cause high CPU usage.","severity":"gotcha","affected_versions":"0.x"},{"fix":"Migrate to pynput (pip install pynput) for cross-platform input control.","message":"The 'inputs' library is no longer actively maintained. Consider using 'pynput' or 'evdev' directly for future development.","severity":"deprecated","affected_versions":"0.5"},{"fix":"Go to System Preferences > Security & Privacy > Privacy > Accessibility and add your terminal app.","message":"macOS support requires additional permissions and may not work without granting accessibility access to the terminal/IDE.","severity":"breaking","affected_versions":"0.5 (macOS)"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use 'from inputs import get_gamepad' (note: 'gamepad' not 'gamepad'). Check pip show inputs version >= 0.4.","cause":"Older version of inputs or misspelled function name.","error":"AttributeError: module 'inputs' has no attribute 'get_gamepad'"},{"fix":"Run script with sudo or add user to 'input' group: sudo usermod -aG input $USER and re-login.","cause":"User lacks read permissions on input device files on Linux.","error":"PermissionError: [Errno 13] Permission denied: '/dev/input/event0'"},{"fix":"Ensure the device is connected and recognized (ls /dev/input/ on Linux). On Windows, install drivers if needed.","cause":"No input device found (e.g., gamepad not connected or driver not loaded).","error":"OSError: [Errno 19] No such device"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}