Project

xkbcommon

0.0
No commit activity in last 3 years
No release in over 3 years
xkbcommon bindings for ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 10.0

Runtime

~> 1.0
 Project Readme

Xkbcommon

xkbcommon bindings for ruby

Installation

Add this line to your application's Gemfile:

gem 'xkbcommon'

And then execute:

$ bundle

Or install it yourself as:

$ gem install xkbcommon

Usage

require 'xkbcommon'

keymap = Xkbcommon::Context.new.keymap_from_names(rules: 'evdev', model: 'pc104', layout: 'de', variant: 'nodeadkeys')

# Available keys in keymap
keymap.keys                 # => [ #<Xkbcommon::Key>, #<Xkbcommon::Key>, ... ]

# Xkbcommon::Key interface
key = keymap.keys.find{ |key| key.name == :A }
key.name                    # => :A
key.scan_code               # => 30
key.code                    # => 38


# Available modifiers in keymap
keymap.modifiers            # => [ #<Xkbcommon::Modifier>, #<Xkbcommon::Modifier>, ... ]

# Xkbcommon::Modifier interface
mod = keymap.modifiers.first
mod.name                    # => :Shift
mod.index                   # => 0
mod.keys.map(&:name)        # => [:LEFTSHIFT], keys activating the modifier


# Available symbols in keymap
keymap.symbols              # => { :Escape => #<Xkbcommon::Symbol>, :"1" => #<Xkbcommon::Symbol>, ... }

# Xkbcommon::Symbol interface
sym = keymap.symbols[:A]
sym.keysym                  # => 65
sym..keys.map(&:name)       # => [:LEFTSHIFT, :A], keys producing the symbol
sym.name                    # => :A
sym.character               # => "A"


# Available characters in keymap
keymap.characters           # => { "\e" => #<Xkbcommon::Symbol>, "1" => #<Xkbcommon::Symbol>, ... }

# Xkbcommon::Symbol interface (see above)