cranvas (version 0.8.5)

match_key: Match keys from a keyboard event

Description

This is a simple wrapper function to test if the given keys are hit in the keyboard event.

Usage

match_key(key, event)

Arguments

key
a character vector of key names (see the example below)
event
the keyboard event (if missing, the default value comes from the event argument of the parent function (sys.frame(1)), so if this function is called under a standard callback of a layer event, we can leave this argument blank)

Value

TRUE for the matched keys, and FALSE for those not matched

References

http://doc.qt.nokia.com/latest/qt.html#Key-enum

Examples

Run this code
library(qtbase)
library(qtpaint)
library(cranvas)
key_press <- function(layer, event) {
    print(match_key(c("A", "F", "PageUp", "1"), event))
}
s <- qscene()
r <- qlayer(s, keyPressFun = key_press)
qplotView(scene = s)

Run the code above in your browser using DataLab