Skip to content

Assigning a key to a certain task in the scene #2672

Discussion options

You must be logged in to vote

Hi Zahra,

You can surely assign a task to a key using Python scripting, you just have to define a function called onKeypressedEvent in a Python controller, and handle the key you are interested in with a simple condition such as if event['key']=='A'
You can find an example in the SofaPython3 plugin, in SofaPython3\examples\liver-scriptcontroller.py.

Also, you can assign tasks to specific keys (such as arrow keys) by using the correspondences defined in SofaPython3\constants\Key.py, which you can import in your Python controller with import Sofa.constants.Key

Best,

Camille

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@zbounik
Comment options

@zbounik
Comment options

@hugtalbot
Comment options

@zbounik
Comment options

@hugtalbot
Comment options

Answer selected by hugtalbot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants