Custom Enum.KeyCode values

Problem

As a Roblox developer, it is currently too hard to…

I have noticed that in Enum.KeyCode, there’s a number of codes that are slated for removal. Furthermore, I also noticed that the World0 to World95 keycodes have been depreciated. This is going to cause an issue since I have written a full replacement for Roblox’s build in ContextActionService. I use use these key codes to indicate the use of various additional user inputs that do not have key codes such as mouse scroll forward and backward, mouse movement, and mouse button clicks (I have discovered there are defined codes for mouse buttons), gyroscope, and accelerometer inputs, etc…

Therefore, I propose one of three solutions:

  1. Reverse the depreciation of the World0-World95 keycodes. I don’t see the reason as to why these would be eventually removed since they are not hurting anything.
  2. Add new key codes for all inputs such as mouse scroll forward/backward, gyroscope, accelerometer, focus, etc…
  3. Introduce custom key codes that can be assigned for any use. Custom0-Custom49 would provide a custom footprint in the key codes enumeration for such uses.

Use Cases

The following use cases are presented.

Use Case Solution 1

Due to the limitation of Roblox’s built-in ContextActionService, I was forced to write a module to fully replace it. That module can be found here: Replacement for Roblox’s ContextActionService. If you look at the code in the module, you can see where I am assigning the World keycodes to mouse actions. Also, these key codes are written back into the InputObject.KeyCode property. From there, the supplied callback is called with the same signature as Roblox’s original ContextActionService. So this is a use case for keeping the World0-World95 keycodes.

Use Case Solution 2

Adding the new key codes for the various input types and having UserInputService fill the keycode values based on the input type would eliminate the need for me to manually assign these keycodes by input type and make processing faster and simpler and I would no longer need to manually assign custom keycodes as the UserInputService itself deals with it.

Use Case Solution 3

Adding custom keycodes Custom0-Custom49 would allow me to keep my current system with minimal code changes.

Additional Information

As such, I realize that this isn’t the intended use for such key codes, but it fits my purposes and makes building a unified input interface much easier to do since most of the code uses key codes anyways.

Conclusion

If Roblox is able to address this issue, it would improve my development experience because it would allow me to continue to use my module to replace the current ContextActionService which many developers seems to be using. It would also allow my module, and those that use it, to process inputs easier without significant retooling.

1 Like