Gravit Designer discussion

Key codes and Input managment


as I understand Gravit Designer uses its own set of key codes, since the constants in GravitDesigner.framework.client.GKey.Constants are different from the raw ones I get from the keydown event on the plain DOM. I.e: plain DOM key code for shift is 16, in GD it’s 6.

How do I listen for input, and how do I get the respective key codes used internally? How do I listen for a specific set of key strokes, like ALT+SHIFT+G. How do I listen for key strokes in a cross platform way? I.e: CMD+S (mac) is CTRL+S (win). … and so on.

Perhaps one can give some general examples which cover this whole topic.


Hi @owzim. You can listen for GKey.Constants inputs by using
GPlatform.modifiers variables. For example, when listening for “keydown” events you could check if the Shift key is pressed by running GravitDesigner.framework.client.GPlatform.modifiers.shiftKey, which will return true (if pressed) or false.
For CMD or CTRL, you can use GravitDesigner.framework.client.GPlatform.modifiers.metaKey and for Option or ALT key you can use GravitDesigner.framework.client.GPlatform.modifiers.optionKey

Hope it helps.