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 and Backspace are treated as the same key #159

Closed
nick-filigree opened this issue Mar 28, 2019 · 1 comment
Closed

[BUG] Delete and Backspace are treated as the same key #159

nick-filigree opened this issue Mar 28, 2019 · 1 comment

Comments

@nick-filigree
Copy link

Describe the bug
Delete and Backspace are different keys, yet react-hotkeys appears to consider them one and the same.

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

Repro case:

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

const keyHandlers = {
  DELETE: e => {
    console.log('DELETE', e ? e.key : undefined);
  },
  BACKSPACE: e => {
    console.log('BACKSPACE', e ? e.key : undefined);
  },
};
const keyMap = {
  DELETE: 'Delete',
  BACKSPACE: 'Backspace',
};

const App = () => (
  <HotKeys keyMap={keyMap} handlers={keyHandlers}>
    <div style={{width: '100px', height: '100px', backgroundColor: 'red'}} />
  </HotKeys>
);

export default App;

Expected behavior
Pressing Delete triggers the DELETE handler, which prints "DELETE Delete" to console; pressing Backspace triggers the BACKSPACE handler, which prints "BACKSPACE Backspace"

Actual behavior
Pressing either backspace or delete triggers the DELETE handler only, with "DELETE Backspace" printed for the backspace key and "DELETE Delete" printed for the delete key.

Platform (please complete the following information):

  • Version of react-hotkey: v2.0.0-pre4
  • Browser: Chrome 73
  • OS: macOS 10.14.3

Are you willing and able to create a PR request to fix this issue?
No -- I'm not familiar with the codebase

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
})
@greena13
Copy link
Owner

Hey @nick-filigree, thanks for taking the time to point this out.

This was intentional and an attempt to be helpful so users of the library did not have to define key mappings for "Mac" Keyboards and "Windows" keyboards (the delete and backspace keys appearing in the same location, respectively). I see now that this was erroneous thinking, and that these keys should not be treated as aliases for one another.

In the next release, they will be treated as separate keys.

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

2 participants