Skip to content

HotKeys not working for form fields/inputs #138

@Fleuv

Description

@Fleuv

Describe the bug
When adding HotKeys to an input it seems not to be added.

**How are you using react hotkeys components?
HotKeys, GlobalHotKeys

Expected behavior
The HotKey handler is triggered even when the input is in focus.

Platform:

  • Version of react-hotkeys: 2.0.0-pre3
  • Browser: firefox
  • OS: ubuntu

Are you willing and able to create a PR request to fix this issue?
No, sorry.

**APPLICABLE TO v2.0.0-pre1 AND ABOVE: ** yes

Include the smallest log that includes your issue:

HotKeys (GLOBAL-E19💚): Started a new combination with 'Enter'. GlobalKeyEventStrategy.js:448
HotKeys (GLOBAL-E19💚): Key history: [
    {
        "keys": {
            "Enter": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Enter": [
                [
                    false,
                    false,
                    false
                ],
                [
                    true,
                    false,
                    false
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    }
]. GlobalKeyEventStrategy.js:449
HotKeys (GLOBAL-E20💙): New 'Enter' keydown event (that has NOT passed through React app). GlobalKeyEventStrategy.js:321
HotKeys (GLOBAL-E20💙): Ignored 'Enter' keydown event because ignoreEventsFilter rejected it. GlobalKeyEventStrategy.js:325
HotKeys (GLOBAL-E20💙): Key history: [
    {
        "keys": {
            "Enter": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Enter": [
                [
                    true,
                    false,
                    false
                ],
                [
                    true,
                    true,
                    false
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    }
]. GlobalKeyEventStrategy.js:460
HotKeys (GLOBAL-E21💛): New 'Enter' keypress event (that has NOT passed through React app). GlobalKeyEventStrategy.js:386
HotKeys (GLOBAL-E21💛): Ignored 'Enter' keypress event because ignoreEventsFilter rejected it. GlobalKeyEventStrategy.js:390
HotKeys (GLOBAL-E21💛): Key history: [
    {
        "keys": {
            "Enter": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    },
    {
        "keys": {
            "Enter": [
                [
                    true,
                    true,
                    false
                ],
                [
                    true,
                    true,
                    true
                ]
            ]
        },
        "ids": [
            "Enter"
        ],
        "keyAliases": {}
    }
]. GlobalKeyEventStrategy.js:460
HotKeys (GLOBAL-E22💜): New 'Enter' keyup event (that has NOT passed through React app). GlobalKeyEventStrategy.js:432
HotKeys (GLOBAL-E22💜): Ignored 'Enter' keyup event because ignoreEventsFilter rejected it. GlobalKeyEventStrategy.js:436

Code to reproduce

Field.jsx

import React, {Component} from 'react';
import {HotKeys} from 'react-hotkeys';

class Field extends Component {
	render() {
		return <HotKeys
			keyMap={{update: 'enter'}}
			handlers={{update: 'handleUpdate'}}
			component={(<input />)}
		/>;
	}

	//...
}

export default Field;

App.jsx

import React, {Component} from 'react';
import {GlobalHotKeys} from 'react-hotkeys';
import Field from './Field';

class App extends Component {
	render() {
		const Container = ({children}) => children;
		return <Container><GlobalHotKeys ... /><Field /></Container>
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions