On 04/07/17 09:50, Carlton Banks wrote: > I am trying to record from my microphone while i press down a button,
First question is which OS? That makes a big difference in this kind of scenario. > the library I am using is not able to detect on hold event. There isn't really any concept of a hold event, you usually have to detect repeated press events. However I don;t know the library you are using, I normally just use the standard library for such things, or build a simple GUI... > It only detect on press, which happens once, That's unusual, usually you get a repeated stream of press events when you hold a key down. But it does depend on the OS and environment. Your library may indeed just be detecting the initial key down and be waiting for the key up event. > So does any of you know any libraries that monitor> state of the keyboard, There are several but it depends on your OS. In the standard library Unix variants can use curses. Windows users have msvcrt. And there are several 3rd party libraries that try to do in a platform independent way - I'm guessing the one you are using is one such. Another way to tackle it is to switch your code so it works with a toggle. Set the toggle to on in the on_press handler. Set it to off in the on_release handler Then trigger a timer loop that runs for as long as the toggle is set. This is probably easiest done within a GUI. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor