Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Delete key is not detected #145

Closed
snaumov opened this issue Feb 12, 2019 · 6 comments
Closed

[BUG] Delete key is not detected #145

snaumov opened this issue Feb 12, 2019 · 6 comments

Comments

@snaumov
Copy link

snaumov commented Feb 12, 2019

Describe the bug
A clear and concise description of what the bug is.

Delete key is not registered (2.0.0-pre.4 version)

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc)

Hotkeys

Expected behavior
A clear and concise description of what you expected to happen.

on delete key pressed, the function should be called

Platform (please complete the following information):

  • Version of react-hotkeys
    2.0.0-pre.4
  • Browser [e.g. chrome, safari]
    Chrome
  • OS: [e.g. iOS]
    Ubuntu 18.10

Are you willing and able to create a PR request to fix this issue?
Yes

APPLICABLE TO v2.0.0-pre1 AND ABOVE: ======================

Include the smallest log that includes your issue:

Set logging to verbose (you'll need the development build if its possible):

import { configure } from 'react-hotkeys';

configure({
  logLevel: 'verbose'
})

What Configuration options are you using?
none

configure({
  //options
})

Codesandbox repro:
https://codesandbox.io/s/wy5qk62528

@snaumov
Copy link
Author

snaumov commented Feb 12, 2019

console output

HotKeys (F3📙-C0🔺-P0🔺:) Focused. 

index.js:26 HotKeys (F3📙-C0🔺-P0🔺:) Component options:
 {
    "actions": {
        "delete": [
            {
                "prefix": "",
                "actionName": "delete",
                "sequenceLength": 1,
                "id": "Backspace",
                "keyDictionary": {
                    "Backspace": true
                },
                "eventBitmapIndex": 0,
                "size": 1
            },
            {
                "prefix": "",
                "actionName": "delete",
                "sequenceLength": 1,
                "id": "Backspace",
                "keyDictionary": {
                    "Backspace": true
                },
                "eventBitmapIndex": 0,
                "size": 1
            }
        ]
    },
    "handlers": {
        "delete": "function _delete() {\n        return _this.handleDelete();\n      }"
    },
    "componentId": 0,
    "options": {
        "defaultKeyEvent": "keydown"
    }
}
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) New 'Delete' keydown event.
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) Started a new combination with 'Delete'.
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) Key history: [
    {
        "keys": {
            "Delete": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Delete": [
                [
                    false,
                    false,
                    false
                ],
                [
                    true,
                    false,
                    false
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    }
].
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) Attempting to find action matching 'Delete' keydown . . .
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) Internal key mapping:
 {
    "sequences": {
        "": {
            "combinations": {
                "Backspace": {
                    "prefix": "",
                    "sequenceLength": 1,
                    "id": "Backspace",
                    "keyDictionary": {
                        "Backspace": true
                    },
                    "size": 1,
                    "events": {
                        "0": {
                            "actionName": "delete",
                            "eventBitmapIndex": 0,
                            "handler": "function _delete() {\n        return _this.handleDelete();\n      }"
                        }
                    }
                }
            }
        }
    },
    "eventBitmap": [
        true,
        false,
        false
    ],
    "longestSequence": 1
}
index.js:26 HotKeys (F3📙-E20💙-C0🔺-P0🔺:) No matching actions found for 'Delete' keydown.
index.js:26 HotKeys (F3📙-E21💛-C0🔺-P0🔺:) New 'Delete' keypress event.
index.js:26 HotKeys (F3📙-E21💛-C0🔺-P0🔺:) Key history: [
    {
        "keys": {
            "Delete": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Delete": [
                [
                    true,
                    false,
                    false
                ],
                [
                    true,
                    true,
                    false
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    }
].
index.js:26 HotKeys (F3📙-E21💛-C0🔺-P0🔺:) Ignored 'Delete' keypress because it doesn't have any keypress handlers.
index.js:26 HotKeys (F3📙-E22💜-C0🔺-P0🔺:) New 'Delete' keyup event.
index.js:26 HotKeys (F3📙-E22💜-C0🔺-P0🔺:) Key history: [
    {
        "keys": {
            "Delete": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Delete": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Delete"
        ],
        "keyAliases": {}
    }
].
index.js:26 HotKeys (F3📙-E22💜-C0🔺-P0🔺:) Ignored 'Delete' keyup because it doesn't have any keyup handlers.
index.js:26 HotKeys (F3📙-C0🔺-P0🔺:) Lost focus.

@snaumov
Copy link
Author

snaumov commented Feb 12, 2019

Turns out I should be using Browser key events: Delete instead of del, as on version 1.x

@snaumov snaumov closed this as completed Feb 12, 2019
@greena13
Copy link
Owner

Thanks for reporting, snaumov.

This is indeed a bug. del should work in the latest pre-release. I've crafted a fix that should go out with the next release.

@wulucxy
Copy link

wulucxy commented Jul 23, 2019

still not work,first cmd + c,then [del , backspace] not work

@wulucxy
Copy link

wulucxy commented Jul 23, 2019

@greena13 is [del, 'backspace'] only work on GlobalHotKeys?

@FrantisekVrab
Copy link

still not work,first cmd + c,then [del , backspace] not work

i think this could be due to some "focus" issues... e.g. like you have loose focus on elements which should listen to these shortcuts..

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

No branches or pull requests

4 participants