WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-27-2013, 05:21 PM
javadi javadi is offline
Member
 
Join Date: Mar 2013
Location: London
Posts: 33
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
Reply With Quote
  #2  
Old 05-06-2013, 09:50 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
If statements and button presses new_horizon Vizard 1 08-23-2011 02:36 AM
Multiple Button Presses new_horizon Vizard 1 08-19-2011 04:58 AM
Count the milliseconds until the user presses a button? Josh Vizard 2 03-24-2010 08:13 AM


All times are GMT -7. The time now is 04:21 PM.


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