WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Key presses, waitKeyDown (https://forum.worldviz.com/showthread.php?t=4560)

javadi 04-27-2013 05:21 PM

Key presses, waitKeyDown
 
Hi

I have a few questions regarding registration of key presses. I noticed that the frequency of registration of key presses using 'waitKeyDown' function depends on the Windows' Keyboard Property, e.g. if you set the 'Repeat Rate' to 'Slow', this function checks the keyboard slower than 'Fast'. I used the following code to test this.

Code:


import viz
import viztask

viz.go()

def Keyinput():
        while True:
                k = yield viztask.waitKeyDown(None)
                print 'key', k.key, 'was pressed'
       
viztask.schedule(Keyinput())

  1. I am wondering whether there is any way to read the keyboard with a certain speed regardless of this property.
  2. Moreover, from our experience of Linux and lots of other tools like Psychtoolbox in MATLAB (even in Windows), we know that key presses can be readout much faster than what 'Keyboard Properties' specifies. For example Psychtoolbox reads keyboard every few milliseconds. How can we read the keyboard with such temporal precision?
  3. One final question. If you press two keys simultaneously, waitKeyDown only returns the latter one. And if you release the latter one, it doesn't return anything anymore, i.e. it doesn't recognise that still one key is pressed. How can we access all the simultaneously pressed keys?

Very many thanks.

Greetings :-)
Amir

farshizzo 05-06-2013 09:50 AM

If you want capture all key presses, then simply register a callback for viz.KEYDOWN_EVENT and viz.KEYUP_EVENT.

You can also use the viz.key.isDown() function to manually query whether a specific key is down. Set the immediate parameter to True to query the physical keyboard, instead of using the last known value.


All times are GMT -7. The time now is 09:07 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC