WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Deactivating Particular keys (https://forum.worldviz.com/showthread.php?t=1582)

Uttama_vizard 07-29-2008 09:32 AM

Deactivating Particular keys
 
Hello,

Is there any way to deactivate any particular key of the keyboard? For mouse, it is there.

Thanks

Uttama

farshizzo 07-29-2008 11:28 AM

I'm not sure exactly what you mean. Can you explain what you are trying to do?

Uttama_vizard 07-31-2008 07:09 AM

Hello,

Actually, I am developing an interactive gave using vizard. In this, a subject has to interact with the game using keys. I want to restrict the number of keys used. So, sometimes, my same key performs different actions in different parts of the interactive game. Say, a 'd' key means Enter at one time and again at another time, 'd' key is to be disregarded, that is it should not activate the Enter function.

In that case, I was trying to deactivate the 'd' key at a later instant, so that even if the subject presses the 'd' key, the Enter function is not activated.

For mouse, there is the Override function...actually I was looking for such a function for keys of the keyboard or keys of an external handheld keyboard.

Thanks

Uttama

farshizzo 07-31-2008 11:40 AM

Depending on how you are handling the different key callbacks, you can unregister the specified key callback when you want it to be deactivated. Then simply register the callback again when you want the key activated. How are you handling the key presses, are you using the vizact.onkeydown functions or the viz.callback functions?

Uttama_vizard 08-01-2008 10:36 AM

Hello,

I am using both. At one point of time, I am using viz.callback and another time, I am using onKeyDown function.

Registering key callback....what you suggested is not clear to me. Can you please elaborate a little bit more?

Thanks

Uttama

farshizzo 08-01-2008 11:10 AM

Here is some sample code showing how to switch between 2 different keydown callback functions. You can press the 1,2 keys to set which callback to use. Pressing spacebar will print out which callback is currently registered.
Code:

import viz
viz.go()

def onKeyDown1(key):
       
        if key == '2':
                viz.callback(viz.KEYDOWN_EVENT,onKeyDown2)
       
        elif key == ' ':
                print 'space pressed in callback 1'
               
def onKeyDown2(key):
       
        if key == '1':
                viz.callback(viz.KEYDOWN_EVENT,onKeyDown1)
       
        elif key == ' ':
                print 'space pressed in callback 2'

viz.callback(viz.KEYDOWN_EVENT,onKeyDown1)



All times are GMT -7. The time now is 01:16 PM.

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