WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-06-2021, 11:27 AM
Roy Roy is offline
Member
 
Join Date: Dec 2019
Posts: 12
key duration

Hi,

How to get duration between a key down and key up during task?

During watching some VR scene (or VR avatar) for 5 sec, I want to measure participants' key-press duration (how long participant presses the key). viztask.waitKeyUp may be suitable, but it terminates the VR scene showing.
Reply With Quote
  #2  
Old 04-19-2021, 03:03 PM
kennethkarthik kennethkarthik is offline
Moderator
 
Join Date: Jul 2018
Posts: 8
Hey Roy,

If you don't want yield statements terminating your scene, I would suggest using the onkeydown and onkeyup function in the vizact library. Use the respective up and down functions to log the time using viz.tick() in global variables and then find the difference to calculate the elapsed time. This should occur without causing any disruption in the scene being run.

Hope it helps.

Best,
Kenneth
Reply With Quote
  #3  
Old 06-11-2021, 01:43 AM
Roy Roy is offline
Member
 
Join Date: Dec 2019
Posts: 12
Hi Kenneth,

Please see the codes which use the onkeydown&up methods as below.

Code:
def keyDown():
	global start
	start = viz.tick()
	print ('key pressed: ' + str(start))
	
def keyUp():
	global start, end, keyTime
	end = viz.tick()
	keyTime = end - start
	print ('key released: ' + str(end))
	print ('key duration: ' + str(keyTime))
As the interactive says below, the key duration (0.0275349) becomes wrong because the duration is calculated by the difference between the keyup time (20.1739211) and last keydown time (20.1463862).
The key duration should be calculated by the first keydown time (19.2442121).
How to fix it?

Quote:
key pressed: 19.2442121
key pressed: 19.7575294
key pressed: 19.7922581
key pressed: 19.8203054
key pressed: 19.8484828
key pressed: 19.8831089
key pressed: 19.9171247
key pressed: 19.9451206
key pressed: 19.9799625
key pressed: 20.0280531
key pressed: 20.0560133
key pressed: 20.0905871
key pressed: 20.1188808
key pressed: 20.1463862
key released: 20.1739211
key duration: 0.0275349
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
logging duration and order of grab/gaze zumbay Vizard 1 11-17-2016 04:48 PM
Avatar eye contact with user as it moves Ducky Vizard 1 03-01-2013 12:23 PM
Randomly and Continuously Change Avatar's Face Texture Karla Vizard 4 08-22-2008 12:14 PM
Problem with getting duration of walkto() ghazanfar Vizard 4 03-23-2007 09:17 AM


All times are GMT -7. The time now is 03:23 AM.


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