kmonad-0.4.1: Advanced keyboard remapping utility

Copyright(c) David Janssen 2019
LicenseMIT
Maintainerjanssen.dhj@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

KMonad.Button

Contents

Description

A button contains 2 actions, one to perform on press, and another to perform on release. This module contains that definition, and some helper code that helps combine buttons. It is here that most of the complicated` buttons are implemented (like TapHold).

Synopsis

Button basics

This section contains the basic definition of KMonad's Button datatype. A Button is essentially a collection of 2 different actions, 1 to perform on Press and another on Release.

data Button Source #

A Button consists of two MonadK actions, one to take when a press is registered from the OS, and another when a release is registered.

onPress :: AnyK () -> Button Source #

Create a new button with only a Press action

mkButton :: AnyK () -> AnyK () -> Button Source #

Create a Button out of a press and release action

NOTE: Since AnyK is an existentially qualified MonadK, the monadic actions specified must be runnable by all implementations of MonadK, and therefore can only rely on functionality from MonadK. I.e. the actions must be pure MonadK.

around Source #

Arguments

:: Button

The outer Button

-> Button

The inner Button

-> Button

The resulting nested Button

Create a new button from 2 buttons, an inner and an outer. When the new button is pressed, first the outer is pressed, then the inner. On release, the inner is released first, and then the outer.

tapOn Source #

Arguments

:: Switch

Which Switch should trigger the tap

-> Button

The Button to tap

-> Button

The tapping Button

Create a new button that performs both a press and release of the input button on just a press or release

Simple buttons

A collection of simple buttons. These are basically almost direct wrappings around MonadK functionality.

emitB :: Keycode -> Button Source #

A button that emits a Press of a keycode when pressed, and a release when released.

modded Source #

Arguments

:: Keycode

The Keycode to `wrap around` the inner button

-> Button

The button to nest inside `being modded`

-> Button 

Create a new button that first presses a Keycode before running an inner button, releasing the Keycode again after the inner Button is released.

layerToggle :: LayerTag -> Button Source #

Create a button that toggles a layer on and off

layerSwitch :: LayerTag -> Button Source #

Create a button that switches the base-layer on a press

layerAdd :: LayerTag -> Button Source #

Create a button that adds a layer on a press

layerRem :: LayerTag -> Button Source #

Create a button that removes the top instance of a layer on a press

pass :: Button Source #

Create a button that does nothing (but captures the input)

cmdButton :: Text -> Button Source #

Create a button that executes a shell command on press

Button combinators

Functions that take Buttons and combine them to form new Buttons.

aroundNext Source #

Arguments

:: Button

The outer Button

-> Button

The resulting Button

A Button that, once pressed, will surround the next button with another.

Think of this as, essentially, a tappable mod. For example, an 'aroundNext KeyCtrl' would, once tapped, then make the next keypress C-whatever.

layerDelay :: Milliseconds -> LayerTag -> Button Source #

Switch to a layer for a period of time, then automatically switch back

layerNext :: LayerTag -> Button Source #

Switch to a layer for the next button-press and switch back automaically.

NOTE: liable to change, this is essentially just aroundNext and layerToggle combined.

tapHold :: Milliseconds -> Button -> Button -> Button Source #

Create a Button that performs a tap of one button if it is released within an interval. If the interval is exceeded, press the other button (and release it when a release is detected).

multiTap :: Button -> [(Milliseconds, Button)] -> Button Source #

Create a Button that contains a number of delays and Buttons. As long as the next press is registered before the timeout, the multiTap descends into its list. The moment a delay is exceeded or immediately upon reaching the last button, that button is pressed.

tapNext :: Button -> Button -> Button Source #

Create a Button that performs a tap of 1 button if the next event is its own release, or else switches to holding some other button if the next event is a different keypress.

tapHoldNext :: Milliseconds -> Button -> Button -> Button Source #

Like tapNext, except that after some interval it switches anyways

tapNextRelease :: Button -> Button -> Button Source #

Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.

It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.

tapHoldNextRelease :: Milliseconds -> Button -> Button -> Button Source #

Create a tap-hold style button that makes its decision based on the next detected release in the following manner: 1. It is the release of this button: We are tapping 2. It is of some other button that was pressed *before* this one, ignore. 3. It is of some other button that was pressed *after* this one, we hold.

If we encounter the timeout before any other release, we switch to holding mode.

It does all of this while holding processing of other buttons, so time will get rolled back like a TapHold button.

tapMacro :: [Button] -> Button Source #

Create a Button that performs a series of taps on press. Note that the last button is only released when the tapMacro itself is released.