Skip to content

How to send a key #1996

Answered by warjort
cl0vvn asked this question in Mod Dev Support
Feb 12, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Key presses typically don't work that way in any programming system.

Key presses are stored internally by the operating system in a buffer/queue which a program will then poll and respond to by executing some routine. The same routine will likely also be bound to mouse/controller events.
This linkage is usually arbitrary, in Minecraft these could be:

  • Player movement controls
  • Menu activation
  • Block activation
  • Item usage
  • GUI interaction, eg. button presses
  • etc.

So what you need to know is what routine/method is bound to F10 or esc in your example(s) above.
This will in general be context sensitive based on what UI is displayed.

But assuming you do know what piece of code should be run,
it …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cl0vvn
Comment options

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