contexts
contexts copied to clipboard
add press key feature
It make it possible to press a specific keyboard key.
(I )press key :char
(I )press key :char on :element
example:
Then I press key "r"
Then I press key "["
Then I press key "ctrl+r"
ready to merge
👍
Good work, I have just one point: the key and modifier arguments need more abstration.
Something like that:
Then I press key "a"
Then I press key "<enter>"
Then I press key "Ctrl+A"
<enter>
is a liddle bit tricky we can have a function convertSpecialKeyToChar($key)
and a convert array for all keys but i think this is not sexy. Do you have another idea?
Do you have another idea?
No, this is what I think, but simpler than a regex:
function convertKey($char)
{
static $specialKeys = [
'<enter>' => 13,
];
list($modifier, $key) = explode('+', $char, 2);
if (isset($specialKeys[$key])) {
$key = $specialKeys[$key];
}
return [$modifier, $key];
}
Not tested and I don’t know if multiple modifiers are supported by mink.