Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Configured the key. How is key cancel?
#2
demor140202 Wrote:I know how to configure the keys by clicking on which something will happen. But how do I cancel these settings? How do I make the key stop calling an action?

Hm.. that depends of your "needs".
If you only want a F7 key to stop working after pressing it, you can always write something like this:

Squirrel Script
  1. local freezeKeyPressed = false
  2.  
  3. addEventHandler("onKey", function(key)
  4. {
  5. switch (key)
  6. {
  7. case KEY_F7:
  8. if (!freezeKeyEnabled)
  9. {
  10. setFreeze(true)
  11. freezeKeyEnabled = true
  12. }
  13. break
  14. }
  15. })



In order to re-enable the F7 functionallity, change the content of the "freezeKeyEnabled" variable back to "false".
Also, maybe you don't want to "disable" the key, but rather after pressing it second time, call the setFreeze(false).

To do that, you can make something like this:
Squirrel Script
  1. local menuVisible = false // dummy variable for example purposes
  2.  
  3. addEventHandler("onKey", function(key)
  4. {
  5. switch (key)
  6. {
  7. case KEY_F7:
  8. menuVisible = !menuVisible // negating a variable content
  9. setFreeze(menuVisible)
  10. break
  11. }
  12. }



Also, do note, that you can add more than one function to a specific event using addEventHandler function.
Reply


Messages In This Thread
RE: Configured the key. How is key cancel? - by Patrix - 24.02.2020, 12:50

Forum Jump:


Users browsing this thread: 1 Guest(s)