Material-ui: Is there have 'keypress' event in <TextField /> ???

Created on 2 Aug 2018  路  2Comments  路  Source: mui-org/material-ui

--------------^ Click "Preview" for a nicer view!

We primarily use GitHub as an issue tracker; for usage and support questions, please check out these resources below. Thanks!


  1. Read the documentation: https://material-ui.com/.
  2. Ask questions on StackOverflow using the tag material-ui: https://stackoverflow.com/questions/tagged/material-ui.
  3. Chat with the community on Gitter: https://gitter.im/mui-org/material-ui.
  4. Ping us on Twitter: https://twitter.com/MaterialUI.

version: v0.20.1

I want use it(TextField) as search, and it can support keypress event ???

question

Most helpful comment

@oliviertassinari
now, I use onKeyDown, and make it.

                            <TextField 
                                type="search"
                                hintText="Search"
                                style={{width: '80%'}}
                                value={searchValue}
                                onChange={this.handleSearch}
                                onKeyDown={this.KeyDown}
                            />

this, I can get the keyCode

All 2 comments

@Mr-jiangzhiguo v0.x is no longer maintained.

it can support keypress event

You have to use the keyboard events and wait for an enter key to be pressed. Even better, you can put the input into a form and wait for the submit event to trigger.

@oliviertassinari
now, I use onKeyDown, and make it.

                            <TextField 
                                type="search"
                                hintText="Search"
                                style={{width: '80%'}}
                                value={searchValue}
                                onChange={this.handleSearch}
                                onKeyDown={this.KeyDown}
                            />

this, I can get the keyCode

Was this page helpful?
0 / 5 - 0 ratings