@accessible/using-keyboard 中文文档教程

发布于 4年前 浏览 22 项目主页 更新于 3年前


<UsingKeyboard>

Bundlephobia Types 代码覆盖率 构建状态 NPM 版本 麻省理工学院许可证

npm i @accessible/using-keyboard

React 实用程序,用于在有人使用键盘导航时向元素添加可访问的焦点样式。

Quick Start

```jsx和谐 进口 { 使用键盘, 身体使用键盘, 使用键盘, } 来自 '@accessibile/using-keyboard'

const App = (props) => (

// This will have the class name 'my-app using-keyboard' // when a keyboard drew the last focus in a document. // That is, during keyboard navigation
) ```

API

useUsingKeyboard(defaultUsingKeyboard)

一个 React 钩子,当键盘比鼠标最近被使用时返回 true 聚焦一个元素。

Arguments

ArgumentTypeRequiredDefaultDescription
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard

Returns boolean

<BodyUsingKeyboard>

一个 React 组件,在最近使用键盘时将 using-keyboard 类添加到 比鼠标聚焦元素。 每次触发 mousedown 事件时,它都会删除该类。

PropTypeRequiredDefaultDescription
classNamestringfalse"using-keyboard"This is the class name that gets appended to the body
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard
childrenReact.ReactElementfalseundefinedBy default this renders no children, but it will render any children you provide here.

<UsingKeyboard>

一个 React 组件,在最近使用键盘时将 using-keyboard 类添加到其子元素 比鼠标聚焦元素。 每次触发 mousedown 事件时,它都会删除该类。

PropTypeRequiredDefaultDescription
classNamestringfalse"using-keyboard"This is the class name that gets appended to the child element
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard
childrenReact.ReactElementfalseundefinedBy default this renders no children, but it will render any children you provide here.

LICENSE

麻省理工学院


<UsingKeyboard>

Bundlephobia Types Code coverage Build status NPM Version MIT License

npm i @accessible/using-keyboard

React utilities for adding accessible focus styles to elements when someone is using keyboard navigation.

Quick Start

```jsx harmony import { UsingKeyboard, BodyUsingKeyboard, useUsingKeyboard, } from '@accessibile/using-keyboard'

const App = (props) => (

// This will have the class name 'my-app using-keyboard' // when a keyboard drew the last focus in a document. // That is, during keyboard navigation
) ```

API

useUsingKeyboard(defaultUsingKeyboard)

A React hook that returns true when the keyboard was used more recently than the mouse for focusing an element.

Arguments

ArgumentTypeRequiredDefaultDescription
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard

Returns boolean

<BodyUsingKeyboard>

A React component that adds a using-keyboard class to the <body> when the keyboard was used more recently than the mouse for focusing an element. It removes the class each time a mousedown event fires.

PropTypeRequiredDefaultDescription
classNamestringfalse"using-keyboard"This is the class name that gets appended to the body
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard
childrenReact.ReactElementfalseundefinedBy default this renders no children, but it will render any children you provide here.

<UsingKeyboard>

A React component that adds a using-keyboard class to its child element when the keyboard was used more recently than the mouse for focusing an element. It removes the class each time a mousedown event fires.

PropTypeRequiredDefaultDescription
classNamestringfalse"using-keyboard"This is the class name that gets appended to the child element
defaultUsingKeyboardbooleanfalsefalseSets the default value of usingKeyboard
childrenReact.ReactElementfalseundefinedBy default this renders no children, but it will render any children you provide here.

LICENSE

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文