Skip to content

How to trigger hotkeys from jest/test-library? #5891

Answered by warpdesign
warpdesign asked this question in Q&A
Discussion options

You must be logged in to vote

I found out why it wasn't working: the mod is converted to ctrlKey or metaKey by detecting the OS using navigator.platform (another deprecated prop... :/):

export const Aliases: IKeyMap = {
    cmd: "meta",
    command: "meta",
    escape: "esc",
    minus: "-",
    mod: isMac() ? "meta" : "ctrl",
    option: "alt",
    plus: "+",
    return: "enter",
    win: "meta",
};

function isMac(platformOverride?: string) {
    // HACKHACK: see https://github.com/palantir/blueprint/issues/5174
    // eslint-disable-next-line deprecation/deprecation
    const platform = platformOverride ?? (typeof navigator !== "undefined" ? navigator.platform : undefined);
    return platform === undefined ? false : 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by warpdesign
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant