9.0.7 • Published 2 days ago

@fluentui/keyboard-keys v9.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

@fluentui/keyboard-keys

Contains a set of keyboard constants for key and keyCode comparison in components. This package contains named key values from The w3 uievents-key specification.

Unicode values are not included since there are a lot of locales to consider and they provide no benefit since unicode characters can be used directly in code.

Usage

import { Enter } from '@fluentui/keyboard-keys';

const onKeyDown = (e: React.KeyboardEvent) => {
  if (e.key === Enter) {
    // ...
  }

  // Unicode characters 'a', '1', '%'...
  // should be used directly in code
  if (e.key === 'a') {
    // ...
  }
};

Legacy keyCode

In order to migrate easily from @fluentui/keyboard-key legacy keyCode support is available in this library but is not encouraged for reuse since this propoerty has been deprecated for a while and will be removed in future standards.

import { keyCodes } from '@fluentui/keyboard-keys';

const onKeyDown = (e: React.KeyboardEvent) => {
  if (e.keyCode === keyCodes.Enter) {
    // ...
  }

  if (e.key === keyCodes.a) {
    // ...
  }
};
9.0.7

6 months ago

9.0.6

8 months ago

9.0.5

8 months ago

9.0.4

9 months ago

9.0.3

1 year ago

9.0.2

1 year ago

9.0.1

2 years ago

0.0.0

2 years ago

9.0.0

2 years ago

9.0.0-rc.5

2 years ago

9.0.0-rc.6

2 years ago

9.0.0-rc.3

2 years ago

9.0.0-rc.4

2 years ago

9.0.0-rc.1

2 years ago

9.0.0-beta.1

3 years ago

9.0.0-alpha.5

3 years ago

9.0.0-alpha.3

3 years ago

9.0.0-alpha.2

3 years ago

9.0.0-alpha.1

3 years ago