decode_modifiers(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

πŸŽ€ decode_modifiers(3) πŸŽ€

okay bestie, so this one lives in the Arcan Lua API and it's genuinely such a slay little helper πŸ’…


✨ NAME ✨

decode_modifiers β€” turns a modifier-bitmap into a textual representation. literally converting keyboard-modifier soup into words you can actually read πŸ”₯


🌸 SYNOPSIS 🌸

modtbl or modstr
decode_modifiers( modval, separator )

πŸ’– DESCRIPTION πŸ’–

so the input table you get handed as part of the _input event handler has a modifiers field, right? and that field is a bitmap of all the different modifier states currently vibing. this function takes that bitmap and converts it into one of two things, depending on what you ask for:

  • an integer-indexed table of text representations β€” one entry per modifier that's actually present, or
  • a single concatenated string, with whatever character you passed in separator dropped between the individual modifiers.

here's the vibe check on which one you get: if the separator argument is provided and it's a non-empty string, then you get modstr back 🫢. otherwise? you get modtbl. no cap, that's the whole rule.

the possible text representations of the modifiers are:

"lshift", "rshift", "lalt", "ralt", "lctrl", "rctrl", "lmeta", "rmeta", "num", "caps", "mode"

that's the full roster, icon behavior only ✨


πŸ¦‹ NOTES πŸ¦‹

  1. if the separator is an empty string, the '_' character will be used as the separator instead. sneaky little default, but okay πŸ‘‘
  2. there's also a modifier bit to indicate whether the event was a repeat (only if the input platform supports that, iykyk). this one will not be added to the decoded output, because it would subtly break a lot of 'naive' approaches to keybindings. so like, it's on purpose. do not come for it πŸ’€

🌈 EXAMPLE 🌈

function decode_modifiers0()
      print( table.concat(decode_modifiers( 0xffffff ), "0) );
      print( decode_modifiers(0xffffff, "_") );
end

πŸ“ sign-off πŸ“

that's the whole page, bestie β€” shipped under system, dated October 2026. go forth and decode those modifiers, main character πŸ§šπŸ’œ

πŸ“¦ where this page comes from