cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MAXScript needs more access to the Keyboard

MAXScript needs more access to the Keyboard

Right now the MAXScript access to keyboard is limited to just modifier keys:

 

  • keyboard.shiftPressed
  • keyboard.controlPressed
  • keyboard.altPressed
  • keyboard.escPressed

 

I propose that there is also a new readonly parameter: keyboard.otherKeyPressed

 

This parameter will return true if any key other than SHIFT, CONTROL, ALT and ESC is pressed.

 

Why would you want this?

 

I built a collection of MacroScripts that I wanted to include a default Alternate Action that would, instead of running the action, take the user to a documentation URL for the action. So I arbitrarily chose the SHIFT key. This way, if the user SHIFT-CLICKS the macroscript in the menu bar, the user will go to the documentation. There is one problem with this: if the user assigns a keyboard shortcut that uses SHIFT, the function won't run as the user expects.

 

If this new parameter is added, you can do something like this in a MacroScript without worrying about colliding with keyboard shortcuts (which require more than a modifier key):

 

if (keyboard.shiftPressed AND NOT keyboard.otherKeyPressed) then (

--do alternate action

) else (

--do primary function

)

 

3 Comments
Swordslayer
Advisor

As a temporary solution, this should work for you:

 

(
	local kbd = dotNetClass "System.Windows.Input.Keyboard"
	local key = dotNetClass "System.Windows.Input.Key"
	local keys = getPropNames key
	local otherKeyPressed = false

	for k in keys where k != #None and k != #DeadCharProcessed and k != #LineFeed and k != #System and k != #LeftShift and k != #RightShift
		while not otherKeyPressed do otherKeyPressed = kbd.IsKeyDown (getProperty key k)

	otherKeyPressed
)
Kelly_Michels
Autodesk
Status changed to: Future Consideration
 
lightcube
Advisor

@Swordslayer Thanks for the info. I tested this and found it to suit my current needs inside a MacroScript. For performance purposes (not looping over the keys array in functions that have a high callback rate), it would still be beneficial to add the otherKeyPressed property.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea