Shellminator V3.0.1
Simple Terminal
|
Did you know that you can assign functionality to specific key combinations? Imagine, with the up, down, left, and right arrows, you could even control servos! Thatโs right, you have the freedom to decide what custom action the Ctrl-C combination (or any other) should trigger, if you need it.
In the demo below, you should see that when you press the arrow keys, the banner text changes to the name of the arrow you just pressed.
If you want to reset the arrow key behavior back to normal, just press CTRL + R.
โ ๏ธ Important note: After pressing CTRL + R, this shortcut will also return to its default function, which is reverse-i-search. The only way to fully reset the demo is to reload the page.
All you need to do is call the corresponding key override function. The table includes all the key combinations you can override.
Function Name | Key Combo |
---|---|
overrideUpArrow() | Up Key |
overrideDownArrow() | Down Key |
overrideLeftArrow() | Left Key |
overrideRightArrow() | Right Key |
overrideAbortKey() | Ctrl-C Combo |
overridePageUpKey() | Page Up Key |
overridePageDownKey() | Page Down Key |
overrideHomeKey() | Home Key |
overrideEndKey() | End Key |
overrideLogoutKey() | Ctrl-D Combo |
overrideSearchKey() | Ctrl-R Combo |
Key override functions work by redirecting control from the default functionality to a callback written by the user (essentially hooks). Because of this, every key override function requires a function that will be called when the specific key is pressed. For example create a callback:
And override the up arrow key behavior:
Similar to key override functions, there are key free functions that restore the default behavior.
Function Name | Key Combo |
---|---|
freeUpArrow() | Up Key |
freeDownArrow() | Down Key |
freeLeftArrow() | Left Key |
freeRightArrow() | Right Key |
freeAbortKey() | Ctrl-C Combo |
freePageUpKey() | Page Up Key |
freePageDownKey() | Page Down Key |
freeHomeKey() | Home Key |
freeEndKey() | End Key |
freeLogoutKey() | Ctrl-D Combo |
freeSearchKey() | Ctrl-R Combo |
Both the key override and key free functions should have the following structure: they should return void
and take one argument, which is Shellminator* caller
. The function name is up to the user, but the return type and argument are fixed.