zeth/inputs

Keyboard blocking while no input

Closed this issue · 2 comments

Hey while working with the keyboard stuff I noticed if there is no input the the execution is blocked.

from __future__ import print_function

from inputs import get_key


def main():
    """Just print out some event infomation when keys are pressed."""
    while 1:
        events = get_key()
        if events:
            for event in events:
                print(event.ev_type, event.code, event.state)
        print("Hello")
        sleep(0.1)


if __name__ == "__main__":
    main()

If you run the following code you'll notice that Hello doesn't print until you press a key. After some further digging I found that it's halting in the _get_data(self, read_size)

    def _get_data(self, read_size):
        """Get data from the character device."""
        return self._character_device.read(read_size) <-- here waiting on a input

I did some digging and couldn't find anything to help stop it from blocking. So if anyone else any ideas please and thank you.

Hey! Look at issue #7 , I found a solution that worked for me

This seems to be solved