Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

add press key feature #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add press key feature #178

wants to merge 1 commit into from

Conversation

gimler
Copy link
Contributor

@gimler gimler commented Jul 6, 2016

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"

@gimler gimler force-pushed the keypress branch 7 times, most recently from ec80534 to 90ac460 Compare July 7, 2016 06:41
@gimler
Copy link
Contributor Author

gimler commented Jul 7, 2016

ready to merge

@stevenkroiher
Copy link

👍

@sanpii
Copy link
Member

sanpii commented Jul 7, 2016

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"

@gimler gimler force-pushed the keypress branch 3 times, most recently from 3dba717 to 75bbff1 Compare July 11, 2016 06:51
@gimler
Copy link
Contributor Author

gimler commented Jul 11, 2016

<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?

@sanpii
Copy link
Member

sanpii commented Jul 11, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants