Accelerators

Posted by Saerataga on Sun 21 May 2023 07:35 PM — 8 posts, 19,781 views.

#0
Good Morning,

How do I test if my keyboard is not locked up by windows for using accelerators?

I get no error or success message so no idea if it's my code or if it's my keyboard.


<plugin
   name="Accelerators"
   author="Saerataga"
   id="aaba23f14107f7cccbc97380"
   language="Lua"
   purpose="Allow short hand typing"
   date_written="2023-05-21 16:08:32"
   requires="5.06"
   version="1.0"
   >
   

  Accelerator ("F11", "volume_down")
  Accelerator ("F12", "volume_up")
  Accelerator ("F1", "flee")
  Accelerator ("F4", "recall")


  -- convert string back into Lua table
  assert (loadstring (GetVariable ("accelerators") or "")) ()

  -- if found, process it
  if accelerators then

    for k, v in ipairs (accelerators) do
       local key, action = string.match (v, "^(%S+) = (.*)$")
       if key then
         Accelerator (key, action)
       end -- if matched
    end -- for

  end -- if



</plugin>



[EDIT] Code tags added.
Amended on Fri 26 May 2023 04:32 AM by Nick Gammon
USA Global Moderator #1
There's a setting in global preferences that must be activated to use F1 (and F6).

As for checking whether Windows is stealing your keystrokes, it's hard to universalize across different programs but there are websites and also downloadable tools you can use to see whether they recognize hitting different keystrokes. One I've used is https://www.keyboardtester.com/
Amended on Mon 22 May 2023 05:56 PM by Fiendish
#2
The keyboard link tells me that my Function keys have to use Func button in addition to F11 or whatever.

However, Accelerators still not working when I use the func button and F11.

Maybe something is wrong with where I put the accelerator declarations?
USA Global Moderator #3
Quote:
Maybe something is wrong with where I put the accelerator declarations?

They look fine to me. Do you have a volume_down alias defined?
Australia Forum Administrator #4
Saerataga said:

The keyboard link tells me that my Function keys have to use Func button in addition to F11 or whatever.

However, Accelerators still not working when I use the func button and F11.


How are you using the Func button? According to the documentation for Accelerator function at http://www.gammon.com.au/scripts/doc.php?function=Accelerator that keystroke is not supported.

For example:

Accelerator ("func+F11", "volume_down")


would not work because Func is not supported.
Australia Forum Administrator #5
Saerataga said:


I get no error or success message so no idea if it's my code or if it's my keyboard.



You can put "check" around (some) function calls, like this:


check (Accelerator ("func+F11", "volume_down"))


That raises an error if the function (ie. Accelerator) does not return eOK as documented.

This "check" function call is not supported for all functions, but if the function documentation says it returns eOK on success, then it is supported.
USA Global Moderator #6
The func button keypress is almost always an in-keyboard differentiator between the F value and whatever media function is the button's primary mode. I don't believe that the operating system treats it as its own key like it does with e.g. Shift or Ctrl. Why that is I'm not sure, but it's probably historical. But anyway MUSHclient shouldn't need to worry about it.

I similarly have an "fn" key on my keyboard that I need to press in conjunction with my F-keys because they're otherwise used to control things like screen brightness and volume. MUSHclient doesn't care about it. I press fn+F1 and MUSHclient activates the F1 macro.
Amended on Fri 26 May 2023 02:57 PM by Fiendish
#7
Thanks guys, I will try adding it and get someone who has a computer that isn't func key to test.